Function: split-string-and-unquote

split-string-and-unquote is a byte-compiled function defined in subr.el.gz.

Signature

(split-string-and-unquote STRING &optional SEPARATOR)

Documentation

Split the STRING into a list of strings.

It understands Emacs Lisp quoting within STRING, such that
  (split-string-and-unquote (combine-and-quote-strings strs)) == strs
The SEPARATOR regexp defaults to "\\s-+".

Other relevant functions are documented in the string group.

View in manual

Probably introduced at or before Emacs version 22.2.

Shortdoc

;; string
(split-string-and-unquote "foo \"bar zot\"")
    => ("foo" "bar zot")

Source Code

;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defun split-string-and-unquote (string &optional separator)
  "Split the STRING into a list of strings.
It understands Emacs Lisp quoting within STRING, such that
  (split-string-and-unquote (combine-and-quote-strings strs)) == strs
The SEPARATOR regexp defaults to \"\\s-+\"."
  (declare (important-return-value t))
  (let ((sep (or separator "\\s-+"))
	(i (string-search "\"" string)))
    (if (null i)
	(split-string string sep t)	; no quoting:  easy
      (append (unless (eq i 0) (split-string (substring string 0 i) sep t))
	      (let ((rfs (read-from-string string i)))
		(cons (car rfs)
		      (split-string-and-unquote (substring string (cdr rfs))
						sep)))))))