baitang36 发表于 2024-2-14 08:58
(defun $zi-chuan-fen-ge$ (str fgf / jg)
;字符串分割
(if (and str (= (type str) 'str) fgf...
用read和vl-princ-to-string可能会有某些意想不到的效果。
我的代码:
(defun mysplit (str delim / lst i len)
(setq len (strlen delim))
(while (setq i (vl-string-search delim str))
(setq lst (cons (substr str 1 i) lst))
(setq str (substr str (+ 1 len i)))
)
(setq lst (cons str lst))
(reverse lst)
) 我用的是如下的方法,没有测试过速度的问题
(setq d (read-line file))
(while (vl-string-search " " d) (setq d (vl-string-subst "" " " d)));如果点号有空格,替换之
(while (vl-string-search "," d) (setq d (vl-string-subst " " "," d)));用空格替换逗号
(setq ddd (read (strcat "(" d ")")));以空格分隔的方式读取点号坐标高程 感谢大佬分享 本帖最后由 yxp 于 2024-3-5 15:53 编辑
函数: (split str p)
用法:用 p 短字符串分割 str 长字符串,返回表,p 支持管道符多个短字符串并列
示例:(split “abcfarecadefge” “c|f”) 返回 (“ab” “are” “ade” “ge”)
(defun split (s p / r)
(setq r (vlax-create-object "vbscript.regexp"))
(vlax-put-property r 'Global 1)
(vlax-put-property r 'Pattern p)
(read (strcat "(\"" (vlax-invoke r 'Replace s "\" \"") "\")"))
)
来自:https://blog.csdn.net/yxp_xa/article/details/72636232
highflybird 发表于 2024-2-19 14:43
用read和vl-princ-to-string可能会有某些意想不到的效果。
我的代码:
对比一下,这个我在用:lol 我不服
但是没办法
页:
1
[2]