- (defun c:tabtolist();程序用来处理字符串,以“\t”为分隔符号,但是当字符串中有“"” ,执行的结果不正确,怎么避免这个错误呢?
- (setq str "300\t65(2 1/2")\t76.1\t190\t149.2 \t22");以\t为分隔符号,将字符串转换成表lst
- (setq tab (chr 9))
- (setq delimiter tab)
- (setq delstr "")
- (setq lst
- (mapcar '(lambda (x)
- (vl-list->string
- (apply 'append
- (mapcar '(lambda (s)
- (if (not (member s (vl-string->list (vl-string-trim " " delstr))))
- (list s)
- )
- )
- (if (vl-string-search " " delstr)
- (vl-string->list (vl-string-trim " " x))
- (vl-string->list x)
- )
- )
- )
- )
- );end_lambda
- (read
- (strcat "(""
- (vl-list->string
- (apply 'append
- (mapcar '(lambda (s)
- (if (member s (vl-string->list delimiter))
- '(34 34)
- (list s)
- )
- )
- (vl-string->list str)
- )
- )
- )
- "")"
- )
- );end_read
- );end_mapcar
- )
- )
程序用来处理字符串,以“\t”为分隔符号,但是当字符串中有“"” ,执行的结果不正确,怎么避免这个错误呢? |