明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2125|回复: 7

[源码] 按通配符选文字

  [复制链接]
发表于 2015-5-10 21: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).



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

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

  10.   (if (and
  11.         (setq ss (ssget (list '(0 . "*TEXT") (cons 1 *qs-text-pattern*))))
  12.         (= 0 (getvar "CMDACTIVE"))
  13.       )
  14.     (progn
  15.       (sssetfirst nil ss)
  16.       (princ (strcat "\n选择了 " (itoa (sslength ss)) " 个对象。"))
  17.     )
  18.   )
  19.   (princ)
  20. )

评分

参与人数 2明经币 +2 收起 理由
USER2128 + 1 赞一个!
Gu_xl + 1 赞一个!

查看全部评分

"觉得好,就打赏"
还没有人打赏,支持一下

本帖被以下淘专辑推荐:

发表于 2015-5-10 23:39 | 显示全部楼层
一直不知道LISP的通配符规定,谢谢
发表于 2015-5-12 13:48 | 显示全部楼层
错误: 输入的字符串有缺陷
 楼主| 发表于 2015-5-12 14:10 | 显示全部楼层
机械工程师 发表于 2015-5-12 13:48
错误: 输入的字符串有缺陷

请提供出现此错误时所使用的通配符,以帮助分析原因。
发表于 2015-5-13 15:24 | 显示全部楼层
可参考小菜的选择易源码
发表于 2015-5-14 08:33 | 显示全部楼层
由于保存代码时按utf保存了,导致加载此文件会出现
错误: 输入的字符串有缺陷
的提示,
用ansi保存就没问题了。

详见下图。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2019-10-30 00:15 来自手机 | 显示全部楼层
谢谢分享,学习了
发表于 2019-11-6 12:01 | 显示全部楼层
感谢大神的分享!谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-2 20:04 , Processed in 0.446684 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表