找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1254|回复: 3

[研讨] 自定义ACET-STR-REPLACE

[复制链接]

已领礼包: 604个

财富等级: 财运亨通

发表于 2013-9-4 12:37:55 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

×
本帖最后由 /db_自贡黄明儒_ 于 2013-9-4 12:39 编辑

没有找到ACET-STR-REPLACE函数,故自定义一个,是否会有相同的结果呢?
  1. (defun ACET-STR-REPLACE1 (o n s)  
  2.   (XD::String:Replace (strcat "[" o "]") s n "I")
  3. )
  4. ;; 用正则表达式替换字符 by 梁雄啸.2007.7
  5. (defun XD::String:Replace (pat str nstr key / end)  
  6.   (vl-load-com)
  7.   (if (not *xxvbsexp)
  8.     (setq *xxvbsexp (vlax-get-or-create-object "VBScript.RegExp"))
  9.   )
  10.   (vlax-put *xxvbsexp 'Pattern pat)
  11.   (if (not key)(setq key ""))
  12.   (setq key (strcase key))
  13.   (setq keys '(("I"  "IgnoreCase")("G"  "Global")("M"  "Multiline")))
  14.   (mapcar '(lambda(x)
  15.              (if (wcmatch key (strcat "*" (car x) "*"))
  16.                (vlax-put *xxvbsexp (read(cadr x)) 0)
  17.                (vlax-put *xxvbsexp (read(cadr x)) -1)
  18.                ))
  19.           keys)
  20.   (vlax-invoke *xxvbsexp 'replace str nstr)
  21. )
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 40个

财富等级: 招财进宝

发表于 2013-9-4 15:23:01 | 显示全部楼层
正则表达式是真强{:soso_e179:}
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 40个

财富等级: 招财进宝

发表于 2013-9-4 15:23:40 | 显示全部楼层
本帖最后由 newer 于 2013-9-4 15:27 编辑

正则表达式是真强{:soso_e179:}
写的很通用,感觉可能会有不适合的吧。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 3884个

财富等级: 富可敌国

发表于 2013-9-4 16:37:31 | 显示全部楼层
(acet-str-replace find replace string [ignoreCase [useRegExp [count]]])

Replace one substring with another.

Arguments
find: The substring to locate.
replace: The replacement substring.
string: The string to search.
ignoreCase: If provided and non-nil, indicates that case insensitive comparisons should be performed.
useRegExp: If provided and non-nil, indicates that regular expressions should be used for searching.
count: The number of times to perform the replacement in string. If count is zero or not supplied then all occurrences are replaced.

This function uses the following definitions for regular expressions:

. Matches any single character.
* Postfix. Preceeding item 0 or more times.
+ Postfix. Preceeding item 1 or more times.
^ Matches empty string at beginning of text.
$ Matches empty string at end of text.
[chars] Matches any character in the given class. If the first character is ^, match any character not in the given class. A range of character may be specified by first-last, as in [A-Z] to specify upper case alphabetic characters.
\( Mark the beginning of a subexpression.
\) Mark the end of a subexpression.
\digit Matches a repeat of the text matched earlier by the subexpression inside the nth opening parenthesis. Subexpressions may also be referenced in replace strings.


Return Values
Returns the resultant string with replacements (if any) made.

是arx里面定义的函数
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-6-15 03:43 , Processed in 0.171275 second(s), 35 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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