本帖最后由 zhynt 于 2011-6-21 16:53 编辑
- ;;将由相同分隔字符分隔的字符串组成表(忽略“空”字串)
- (defun zhy_string_tok (sstring sstr / n1 n2 m2 str_1 string_list)
- (setq string_list '())
- (setq n1 (strlen sstring))
- (setq n2 (strlen sstr))
- (while (setq m2 (zhy_string_find sstring sstr))
- (setq str_1 (substr sstring 1 (- m2 1)))
- (setq sstring (substr sstring (+ m2 n2)))
- (if (/= str_1 "")
- (setq string_list (cons str_1 string_list))
- )
- )
- (if (/= sstring "")
- (setq string_list (cons sstring string_list))
- )
- (reverse string_list)
- )
- ;;======================================================
- (defun str (str)
- (setq str_lst (zhy_string_tok str " "))
- (setq n (length str_lst))
- (setq st1 '()
- st2 '()
- m 0
- )
- (while (/= n m)
- (setq st1 (cons (substr (nth m str_lst) 1 1) st1)
- st2 (cons (substr (nth m str_lst) 2) st2)
- m (1+ m)
- )
- )
- (setq st1 (reverse st1)
- st2 (reverse st2)
- )
- )
(setq string "X-12.0314 Y26.9145 I48.7961 J-14.9177")
(str string)
st1==>
("X" "Y" "I" "J")
st2==>
("-12.0314" "26.9145" "48.7961" "-14.9177")
|