[源码] 最快的字串分割方法
(defun $zi-chuan-fen-ge$ (str fgf / jg);字符串分割
(if (and str (= (type str) 'str) fgf (= (type fgf) 'str))
(progn
(setq str (vl-prin1-to-string str))
(while (wcmatch str (STRCAT "[,*`" FGF "*,]"))
(setq str (vl-string-subst "\"\"" fgf str))
)
(setq jg (read (strcat "(" str ")")))
)
)
jg
)
(defun $zi-chuan-fen-ge$ (str fgf / jg)
;字符串分割
(if (and str (= (type str) 'str) fgf (= (type fgf) 'str))
(progn
(setq str (vl-prin1-to-string str))
(while (wcmatch str (STRCAT "[,*`" FGF "*,]"))
(setq str (vl-string-subst "\"\"" fgf str))
)
(setq jg (read (strcat "(" str ")")))
)
)
jg
)
(defun syz-zi-chuan-fen-ge (str fgf)
;(setq fgf "明经")
(if (and str (= (type str) 'str) fgf (= (type fgf) 'str))
(progn
(setq i 1
k 1
)
(setq jg nil)
(while (< i (+ 1 (- (strlen str) (strlen fgf))))
(setq str2 (substr str i (strlen fgf)))
(if (equal str2 fgf)
(progn
(setq jg (append jg (list (substr str k (- i k)))))
(setq k (+ i (strlen fgf)))
(setq i (+ i (strlen fgf)))
)
(setq i (+ 1 i))
)
)
)
)
)
(setq str "s")
(setq j 0)
(repeat 6000
(setq str (strcat str
"测试字符串1234567阿布炒大白菜的abcd"
(itoa j)
"明经"
)
)
(setq j (+ 1 j))
)
(princ (strlen str))
(setq t0 (getvar "TDUSRTIMER"))
(syz-zi-chuan-fen-ge str "明经")
;($zi-chuan-fen-ge$ str "明经")
(princ "\n程序共用时")
(princ (* (- (getvar "TDUSRTIMER") t0) 86400))
(princ "秒")
(princ)
页:
[1]