vectra 发表于 2015-5-10 21:24:24

按通配符选文字

通配符参考wmatch说明,方便根据内容来快速筛选文字对象。

Wild-card characters

Character
Definition

# (pound)
Matches any single numeric digit.

@ (at)
Matches any single alphabetic character.

. (period)
Matches any single nonalphanumeric character.

* (asterisk)
Matches any character sequence, including an empty one, and it can be used anywhere in the search pattern: at the beginning, middle, or end.

? (question mark)
Matches any single character.

~ (tilde)
If it is the first character in the pattern, it matches anything except the pattern.

[...]
Matches any one of the characters enclosed.

[~...]
Matches any single character not enclosed.

- (hyphen)
Used inside brackets to specify a range for a single character.

, (comma)
Separates two patterns.

` (reverse quote)
Escapes special characters (reads next character literally).



(defun c:qs (/ rt ss)
(if (null *qs-text-pattern*)
    (setq *qs-text-pattern* "C#,M#,FM#")
)

(if (/= ""
          (setq rt (getstring (strcat "\n输入文字内容通配符 <\"" *qs-text-pattern* "\">: ")))
      )
    (setq *qs-text-pattern* rt)
)

(if (and
        (setq ss (ssget (list '(0 . "*TEXT") (cons 1 *qs-text-pattern*))))
        (= 0 (getvar "CMDACTIVE"))
      )
    (progn
      (sssetfirst nil ss)
      (princ (strcat "\n选择了 " (itoa (sslength ss)) " 个对象。"))
    )
)
(princ)
)

Rimford 发表于 2015-5-10 23:39:30

一直不知道LISP的通配符规定,谢谢

机械工程师 发表于 2015-5-12 13:48:57

错误: 输入的字符串有缺陷

vectra 发表于 2015-5-12 14:10:27

机械工程师 发表于 2015-5-12 13:48 static/image/common/back.gif
错误: 输入的字符串有缺陷

请提供出现此错误时所使用的通配符,以帮助分析原因。

Throne 发表于 2015-5-13 15:24:18

可参考小菜的选择易源码

机械工程师 发表于 2015-5-14 08:33:18

由于保存代码时按utf保存了,导致加载此文件会出现
错误: 输入的字符串有缺陷
的提示,
用ansi保存就没问题了。

详见下图。

happy336 发表于 2019-10-30 00:15:01

谢谢分享,学习了

sdls 发表于 2019-11-6 12:01:47

感谢大神的分享!谢谢!
页: [1]
查看完整版本: 按通配符选文字