New version for problems with multiple separator: "\"Smith,,,,,John\",123"
; Version 1.01 - 11-04-2013
(defun ALE_String_CdfToList (InpStr CarDlm / SttPos EndPos TmpStr OutLst TmpElm)
(setq CarDlm (ascii CarDlm) SttPos 0 EndPos (vl-string-position CarDlm InpStr))
(while EndPos
(cond
( (wcmatch (setq TmpElm (substr InpStr (1+ SttPos) (- EndPos SttPos))) "\"*\"")
(setq OutLst (cons (ALE_StringSubstAll "\"" "\"\"" (substr TmpElm 2 (- (strlen TmpElm) 2)) 0) OutLst))
)
( (wcmatch TmpElm "\"*") (setq TmpStr (substr TmpElm 2)) )
( (= TmpElm "") (if TmpStr (setq TmpStr (strcat TmpStr ",")) (setq TmpStr ",")) )
( TmpStr
(setq
OutLst (cons (strcat TmpStr (chr CarDlm) (substr TmpElm 1 (- (strlen TmpElm) 1))) OutLst)
TmpStr nil
)
)
( T (setq OutLst (cons TmpElm OutLst)) )
)
(setq SttPos (1+ EndPos) EndPos (vl-string-position CarDlm InpStr SttPos))
)
(reverse
(cons
(cond
( (wcmatch (setq TmpElm (substr InpStr (1+ SttPos))) "\"*\"")
(ALE_StringSubstAll "\"" "\"\"" (substr TmpElm 2 (- (strlen TmpElm) 2)) 0)
)
( (wcmatch TmpElm "\"*")(setq TmpStr (substr TmpElm 2)) )
( TmpStr (strcat TmpStr (chr CarDlm) (substr TmpElm 1 (- (strlen TmpElm) 1))) )
( T TmpElm )
)
OutLst
)
)
)
Comando: (ALE_String_CdfToList "\"Smith,,,,,John\",123" ",")
("Smith,,,,,John" "123")