只需一步,快速开始
各位高手能不能设计一个LISP程序拆分字符串,
比如CAD里有个字符串是“0.3-0.8”,运行设计的LISP后,选择这个字符串,会拆分为“0.3”,“0.8”两个。谢谢了
还有比如“0.3-0.8-1.2”三组的能不能也拆分为“0.3”,“0.8”,“1.2”
使用道具 举报
使用以下语句,得到b b1 b2即为所需要的值:
(setq a2 "0.3-0.8-1.2")
(setq a3 (vl-string-position (ascii "-") a2)) (setq a4 (vl-string-position (ascii "-") a2 (+ a3 1))) (setq b (substr a2 1 a3)) (setq b1 (substr a2 (+ a3 2) (- a4 a3 1)) ) (setq b2 (substr a2 (+ a4 2)) )
本版积分规则 发表回复 回帖后跳转到最后一页
小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 ) ©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途
GMT+8, 2025-2-27 16:19 , Processed in 0.172707 second(s), 25 queries , Gzip On.
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.