Function: string-split

string-split is a function alias for split-string, defined in subr.el.gz.

Signature

(string-split STRING &optional SEPARATORS OMIT-EMPTY TRIM)

Documentation

Split STRING into substrings bounded by matches for SEPARATORS.

The beginning and end of STRING, and each match for SEPARATORS, are splitting points. The substrings matching SEPARATORS are removed, and the substrings between the splitting points are collected as a list, which is returned.

If SEPARATORS is non-nil, it should be a regular expression matching text that separates, but is not part of, the substrings. If omitted or nil, it defaults to split-string-default-separators, whose value is normally "[ \\f\\t\\n\\r\\v]+", and OMIT-EMPTY is then forced to t. SEPARATORS should never be a regexp that matches the empty string.

If OMIT-EMPTY is t, zero-length substrings are omitted from the list (so that for the default value of SEPARATORS leading and trailing whitespace are effectively trimmed). If nil, all zero-length substrings are retained, which correctly parses CSV format, for example.

If TRIM is non-nil, it should be a regular expression to match text to trim from the beginning and end of each substring. If trimming makes the substring empty and OMIT-EMPTY is t, it is dropped from the result.

Note that the effect of (split-string STRING) is the same as
(split-string STRING split-string-default-separators t). In the rare
case that you wish to retain zero-length substrings when splitting on whitespace, use (split-string STRING split-string-default-separators).

Modifies the match data; use save-match-data if necessary.

Probably introduced at or before Emacs version 29.1.

Aliases

string-split