![](source/plugin/imc_colorcode/images/loading.gif)
- ;;;====================================================
- ;;; 函数三
- ;;;功能:分割字符串,按照是否为数字分
- ;;;参数:STR ----欲分割的字符串
- ;;;返回:分割后的表
- ;;;示例:(ZL-STR-SUB3 "A-11b")
- ;;; ====> ("A-" "11" "b")
- (defun ZL-STR-SUB3 (STR / STRI STR_TMP LST LX0 LX1)
- ;;获取第一个字符
- (if (> (ascii (substr STR 1 1)) 159)
- (progn
- (setq STRI (substr STR 1 2)
- STR (substr STR 3)
- )
- (setq LX0 1) ;0 为数字;1 为非数字
- )
- (progn
- (setq STRI (substr STR 1 1)
- STR (substr STR 2)
- )
- (if (or ;;(= (ascii STRI) 46)
- (<= 48 (ascii STRI) 57)
- )
- (setq LX0 0) ;0 为数字;1 为非数字
- (setq LX0 1)
- )
- )
- )
- ;;
- (setq LST '())
- (setq STR_TMP STRI)
- ;;循环执行全部
- (while (/= STR "")
- (if (> (ascii (substr STR 1 1)) 159)
- (progn (setq STRI (substr STR 1 2)
- STR (substr STR 3)
- )
- (setq LX1 1) ;0 为数字;1 为非数字
- )
- (progn
- (setq STRI (substr STR 1 1)
- STR (substr STR 2)
- )
- (cond ((<= 48 (ascii STRI) 57)
- (setq LX1 0) ;0 为数字;1 为非数字
- )
- ((and (= LX0 0)
- (= (ascii STRI) 46)
- )
- (setq LX1 0) ;0 为数字;1 为非数字
- )
- (t
- (setq LX1 1) ;0 为数字;1 为非数字
- )
- )
- )
- )
- (if (= LX1 LX0)
- (setq STR_TMP (strcat STR_TMP STRI))
- (setq LST (cons STR_TMP LST)
- STR_TMP STRI
- LX0 LX1
- )
- )
- ) ;_结束while
- ;;
- (if (= STR_TMP "")
- ()
- (setq LST (cons STR_TMP LST))
- )
- ;;
- (reverse LST)
- )
|