Lee how about this one?
;;; Split a string into portions of specified char-sets
(defun split-parse-char (char-sets str / cur-char-set cur-char-set-idx current lst)
(setq char-sets (mapcar 'vl-string->list char-sets))
(foreach char (vl-string->list str)
(setq cur-char-set-idx -1)
(if (vl-some '(lambda (char-set / pos)
(setq cur-char-set-idx (1+ cur-char-set-idx))
(vl-position char char-set)
)
char-sets
)
(if (vl-position char cur-char-set)
(setq current (cons char current))
(setq lst (cons current lst)
current (list char)
cur-char-set (nth cur-char-set-idx char-sets)
)
)
(setq lst (cons current lst) current nil)
)
)
(setq lst (cons current lst))
(mapcar '(lambda (portion) (vl-list->string (reverse portion))) (reverse (vl-remove-if 'null lst)))
)
;;; Parse a string into its number portions, including real numbers and fractions
(defun parsenum (str /)
(mapcar
'(lambda (portion) (if (wcmatch portion "*/*") (distof portion) (read portion)))
(split-parse-char '("0123456789.-/") str)
)
)
I have other uses also for that split-parse-char
![Wink ;)](http://www.theswamp.org/Smileys/black/wink.gif)
. It's a bit over the top for this case, but I didn't go and re-invent the wheel. Probably you'll come up with a simpler method of doing that as well!
OK I see, you would need distof to extract fractions.
That seems to work, though if there's any decimals around the distof seems to give a nil result on fractions. Not that fractions "aught" to have decimals mixed up inside them, but consider the following result:
_$ (parsenum "123/50 1.0/3 2/5.6 -78")
(2.46 nil nil -78)
And you do need to use it only on fractions, otherwise all the integers gets returned as floating point.