Function: dired-split
dired-split is a byte-compiled function defined in dired-aux.el.gz.
Signature
(dired-split PAT STR &optional LIMIT)
Documentation
Splitting on regexp PAT, turn string STR into a list of substrings.
Optional third arg LIMIT (>= 1) is a limit to the length of the resulting list. Thus, if SEP is a regexp that only matches itself,
(mapconcat #'identity (dired-split SEP STRING) SEP)
is always equal to STRING.
Source Code
;; Defined in /usr/src/emacs/lisp/dired-aux.el.gz
;; There should be a builtin split function - inverse to mapconcat.
(defun dired-split (pat str &optional limit)
"Splitting on regexp PAT, turn string STR into a list of substrings.
Optional third arg LIMIT (>= 1) is a limit to the length of the
resulting list.
Thus, if SEP is a regexp that only matches itself,
(mapconcat #'identity (dired-split SEP STRING) SEP)
is always equal to STRING."
(let* ((start (string-match pat str))
(result (list (substring str 0 start)))
(count 1)
(end (if start (match-end 0))))
(if end ; else nothing left
(while (and (or (not (integerp limit))
(< count limit))
(string-match pat str end))
(setq start (match-beginning 0)
count (1+ count)
result (cons (substring str end start) result)
end (match-end 0)
start end)
))
(if (and (or (not (integerp limit))
(< count limit))
end) ; else nothing left
(setq result
(cons (substring str end) result)))
(nreverse result)))