求文字去括号lsp,包括圆括号和方括号
如题,求哪位大神上传一个lsp文件,谢谢!感谢上面发的东西下来看看 感谢 edata 分享程序!!!! 将圆括号方括号去掉就行?
去掉字符串的圆方括号。。;;去掉字符串中的圆括号、方括号函数
;;edit by edata 2013年9月13日0:44:22
;; (sk_txt# str)
;;返回没有圆括号、方括号的字符串
(defun sk_txt# (str / i stri tmp)
(if str
(progn
(setq i1
tmp""
lst'()
)
(while (/= (setq stri (substr str i 1)) "")
(setq stri (substr str i 1))
(if (or (= stri "(") (= stri ")") (= stri "[") (= stri "]"))
(princ)
(setq tmp (strcat tmp stri))
)
(setq i (1+ i))
)
(setq lst (reverse (cons tmp lst)))
lst
)
)
)
;;测试
(defun c:tt (/ str)
(setq str "abcd(())[]dsds")
(print (sk_txt# str))
(princ)
)
首先谢谢edata大神的帮忙,我是一个新手,把您的代码做成lsp,之后进行加载,运行tt后没有反应,还得请您出手指点一下!
edata 发表于 2013-9-13 00:48 static/image/common/back.gif
去掉字符串的圆方括号。。
edata大神,您写的代码,我运行之后有点小问题,可能是我操作不当,还请您指点一下,谢谢大神! 本帖最后由 edata 于 2013-9-13 17:37 编辑
狼魔 发表于 2013-9-13 17:09 static/image/common/back.gif
edata大神,您写的代码,我运行之后有点小问题,可能是我操作不当,还请您指点一下,谢谢大神!;;去掉字符串中的圆括号、方括号函数
;;edit by edata 2013年9月13日0:44:22
;; (sk_txt# str)
;;返回没有圆括号、方括号的字符串
(defun sk_txt# (str / i stri tmp)
(if str
(progn
(setq i1
tmp""
lst'()
)
(while (/= (setq stri (substr str i 1)) "")
(setq stri (substr str i 1))
(if (or (= stri "(") (= stri ")") (= stri "[") (= stri "]"))
(princ)
(setq tmp (strcat tmp stri))
)
(setq i (1+ i))
)
(setq lst (reverse (cons tmp lst)))
(car lst)
)
)
)
;;测试
(defun c:tt (/ str)
(setq str "abcd(())[]dsds") ;;将str的"abcd(())[]dsds"换成你需要去掉的字符串
(print (sk_txt# str));;(sk_txt# str)将返回没有括号的字符串
(princ)
)局部修改了下。。
你需要把你要去掉的括号数据拿出来看看。。有样板才能有针对性。
edata 发表于 2013-9-13 17:34 static/image/common/back.gif
局部修改了下。。
你需要把你要去掉的括号数据拿出来看看。。有样板才能有针对性。
edata大神,很不好意思再次打扰您,我想批量去括号,想实现的功能已经截图了,谢谢大神!
狼魔 发表于 2013-9-13 17:51 static/image/common/back.gif
edata大神,很不好意思再次打扰您,我想批量去括号,想实现的功能已经截图了,谢谢大神!
(defun c:tt(/ i ss source_text res_txt)
(vl-load-com)
(prompt "\n选择文字")
(if (setq ss (ssget'((0 . "*TEXT"))))
(progn
(setq i 0)
(repeat (sslength ss)
(setq en1 (ssname ss i)
ob (vlax-ename->vla-object en1)
)
(setq source_text(vla-get-TextString ob))
(setq res_txt (sk_txt# source_text))
(vla-put-TextString ob res_txt)
(setq i (1+ i))
)
))
(princ)
)
;;去掉字符串中的圆括号、方括号函数
;;edit by edata 2013年9月13日0:44:22
;; (sk_txt# str)
;;返回没有圆括号、方括号的字符串
(defun sk_txt# (str / i stri tmp)
(if str
(progn
(setq i1
tmp""
lst'()
)
(while (/= (setq stri (substr str i 1)) "")
(setq stri (substr str i 1))
(if (or (= stri "(") (= stri ")") (= stri "[") (= stri "]"))
(princ)
(setq tmp (strcat tmp stri))
)
(setq i (1+ i))
)
(setq lst (reverse (cons tmp lst)))
(car lst)
)
)
)
edata 发表于 2013-9-13 18:39 static/image/common/back.gif
edata大神,谢谢您,这次试验就是我想要的效果,谢谢大神!谢谢! 学习了,谢谢。
页:
[1]
2