Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
3aeea9e9
Commit
3aeea9e9
authored
May 22, 2003
by
Juanma Barranquero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(Creating Strings): Update split-string specification and examples.
parent
6a646626
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
13 deletions
+29
-13
lispref/strings.texi
lispref/strings.texi
+29
-13
No files found.
lispref/strings.texi
View file @
3aeea9e9
...
...
@@ -259,30 +259,46 @@ description of @code{mapconcat} in @ref{Mapping Functions},
Lists}.
@end defun
@defun split-string string separators
@defun split-string string separators
omit-nulls
This function splits @var{string} into substrings at matches for the regular
expression @var{separators}. Each match for @var{separators} defines a
splitting point; the substrings between the splitting points are made
into a list, which is the value returned by @code{split-string}.
into a list, which is the value returned by @code{split-string}. If
@var{omit-nulls} is @code{t}, null strings will be removed from the
result list. Otherwise, null strings are left in the result.
If @var{separators} is @code{nil} (or omitted),
the default is
@code{"[ \f\t\n\r\v]+"
}.
the default is
the value of @code{split-string-default-separators
}.
For example,
@defvar split-string-default-separators
The default value of @var{separators} for @code{split-string}, initially
@samp{"[ \f\t\n\r\v]+"}.
As a special case, when @var{separators} is @code{nil} (or omitted),
null strings are always omitted from the result. Thus:
@example
(split-string "Soup is good food" "o")
@result{} ("S" "up is g" "" "d f" "" "d")
(split-string "Soup is good food" "o+")
@result{} ("S" "up is g" "d f" "d")
(split-string " two words ")
@result{} ("two" "words")
@end example
The result is not @samp{("" "two" "words" "")}, which would rarely be
useful. If you need such a result, use an explict value for
@var{separators}:
@example
(split-string " two words " split-string-default-separators)
@result{} ("" "two" "words" "")
@end example
When there is a match adjacent to the beginning or end of the string,
this does not cause a null string to appear at the beginning or end
of the list:
More examples:
@example
(split-string "out to moo" "o+")
@result{} ("ut t" " m")
(split-string "Soup is good food" "o")
@result{} ("S" "up is g" "" "d f" "" "d")
(split-string "Soup is good food" "o" t)
@result{} ("S" "up is g" "d f" "d")
(split-string "Soup is good food" "o+")
@result{} ("S" "up is g" "d f" "d")
@end example
Empty matches do count, when not adjacent to another match:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment