FunctionPackage: exclToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.2
Moderately revised from 8.1.
8.1 version

split-re

Arguments: regexp string &key count (start 0) end (return :string) case-fold single-line multiple-lines ignore-whitespace

Warning: incompatible change by patch. This function was updated with a patch released in February, 2013. The patch makes this function similar to the equivalent function in Perl. See below for information on how the behavior has changed (aside from the new limit keyword argument, some forms which errored now return values and nil is returned in some cases where previously ("") was returned.

This function scans string for a delimiter given by regexp and returns a list of substrings. If count is given, then split into no more than count substrings, in which case the last substring will contain the rest of the string. If start and end are specified, the whole string is scanned but only delimiters between start (inclusive) and end (exclusive) are considered.

If count is given, then split into no more than count substrings, in which case the last substring will contain the rest of the string.

regexp should match a non-zero length string, or an error is signaled.

The return argument can be :string (the default, the return value will be a list of strings) or :index (the return value will be a list of dotted pairs or indexes into string corresponding to the substrings that would have been returned if return was :string). See the example.

See the section Matching mode in the regexp2 module in regexp.htm for information on the case-fold, single-line, multiple-lines, and ignore-whitespace keyword arguments.

The symbol naming this operator is also exported from the regexp package.

Examples

(excl:split-re "-" "a-b-c-d")
  --> ("a" "b" "c" "d")
(split-re ":" "1:2:3:4:5")
  --> ("1" "2" "3" "4" "5")
(split-re ":" "1:2:3:4:5" :return :index)
  --> ((0 . 1) (2 . 3) (4 . 5) (6 . 7) (8 . 9))
(split-re ":" "1:2:3:4:5" :count 2)
  --> ("1" "2" "3:4:5")
(split-re ":" "1:2:3:4:5" :start 2)
  --> ("1:2" "3" "4" "5")
(split-re ":" "1:2:3:4:5" :start 2 :return :index)
  --> ((0 . 3) (4 . 5) (6 . 7) (8 . 9))

cl-user(23): (split-re "/+" "abc/def")
("abc" "def")
cl-user(24): (split-re "/+" "/abc//def///ghi")
("" "abc" "def" "ghi")
cl-user(25): 

See The new regexp2 module in regexp.htm for further information on this function and the regexp2 module.


Copyright (c) 1998-2015, Franz Inc. Oakland, CA., USA. All rights reserved.
This page has had moderate revisions compared to the 8.1 page.
Created 2010.1.21.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.2
Moderately revised from 8.1.
8.1 version