wzg356 发表于 2016-3-21 20:04
函数呢?_strsplit
不好意思,缺了一个LLSheng_73的函数,主贴已经更新- ;;超级字符串分割
- ;;用一个表对字符串进行分割,返回两个表
- ;;表1:分割后的字符串表
- ;;表2:被分割的字符串表
- ;(_STRSPLIT "12+34分隔35-454,22,33-45" '("+""-""*"","";"" ""=""分隔") nil)
- ;==>(("12" "34" "35" "454" "22" "33" "45") ("+" "分隔" "-" "," "," "-" ""))
- (defun _strsplit(str splits f / i a b l );;BY:LLSheng_73
- (if f(setq str(vl-list->string(vl-remove 32(vl-string->list str)))))
- (while(<""str)
- (if(vl-remove'nil(mapcar'(lambda(x)(vl-string-search x str))splits))
- (setq i(car(vl-sort(vl-remove'nil(mapcar'(lambda(x)(if(setq l(vl-string-search x str))(cons l x)))splits))
- '(lambda(s1 s2)(<(car s1)(car s2)))))
- a(cons(substr str 1(car i))a)b(cons(cdr i)b)
- str(substr str(+(car i)(strlen(cdr i))1)))
- (setq a(cons str a)b(cons "" b)str"")))
- (list(reverse a)(reverse b)))
|