/[emacs]/emacs/lispref/strings.texi
ViewVC logotype

Diff of /emacs/lispref/strings.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.23 by lektu, Tue Feb 4 14:47:54 2003 UTC revision 1.24 by lektu, Thu May 22 21:05:25 2003 UTC
# Line 259  description of @code{mapconcat} in @ref{ Line 259  description of @code{mapconcat} in @ref{
259  Lists}.  Lists}.
260  @end defun  @end defun
261    
262  @defun split-string string separators  @defun split-string string separators omit-nulls
263  This function splits @var{string} into substrings at matches for the regular  This function splits @var{string} into substrings at matches for the regular
264  expression @var{separators}.  Each match for @var{separators} defines a  expression @var{separators}.  Each match for @var{separators} defines a
265  splitting point; the substrings between the splitting points are made  splitting point; the substrings between the splitting points are made
266  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
267    @var{omit-nulls} is @code{t}, null strings will be removed from the
268    result list.  Otherwise, null strings are left in the result.
269  If @var{separators} is @code{nil} (or omitted),  If @var{separators} is @code{nil} (or omitted),
270  the default is @code{"[ \f\t\n\r\v]+"}.  the default is the value of @code{split-string-default-separators}.
271    
272  For example,  @defvar split-string-default-separators
273    The default value of @var{separators} for @code{split-string}, initially
274    @samp{"[ \f\t\n\r\v]+"}.
275    
276    As a special case, when @var{separators} is @code{nil} (or omitted),
277    null strings are always omitted from the result.  Thus:
278    
279  @example  @example
280  (split-string "Soup is good food" "o")  (split-string "  two words ")
281  @result{} ("S" "up is g" "" "d f" "" "d")  @result{} ("two" "words")
282  (split-string "Soup is good food" "o+")  @end example
283  @result{} ("S" "up is g" "d f" "d")  
284    The result is not @samp{("" "two" "words" "")}, which would rarely be
285    useful.  If you need such a result, use an explict value for
286    @var{separators}:
287    
288    @example
289    (split-string "  two words " split-string-default-separators)
290    @result{} ("" "two" "words" "")
291  @end example  @end example
292    
293  When there is a match adjacent to the beginning or end of the string,  More examples:
 this does not cause a null string to appear at the beginning or end  
 of the list:  
294    
295  @example  @example
296  (split-string "out to moo" "o+")  (split-string "Soup is good food" "o")
297  @result{} ("ut t" " m")  @result{} ("S" "up is g" "" "d f" "" "d")
298    (split-string "Soup is good food" "o" t)
299    @result{} ("S" "up is g" "d f" "d")
300    (split-string "Soup is good food" "o+")
301    @result{} ("S" "up is g" "d f" "d")
302  @end example  @end example
303    
304  Empty matches do count, when not adjacent to another match:  Empty matches do count, when not adjacent to another match:

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26