FunctionPackage: exclToCDocOverviewCGDocRelNotesIndexPermutedIndex
Allegro CL version 7.0
This page is new in 7.0.

re-submatch

Arguments: regexp string indexes selector &key (type :string)

This is a convenience function to extract a specified submatch information from the value returned by match-re.

regexp should be a compiled regexp, and indexes should be a list of (start . end) index pairs returned by match-re. selector should be an integer that specifies a captured submatch (or 0 for the whole match), or a string or a symbol that names a named submatch.

Alternatively, you can pass the opaque 'match' object returned by match-re with :return :match argument, as regexp. The match object knows the information about the match results, so you don't need string and indexes; just pass nil to them.

The type argument may be :string, :after, :before or :index. It specifies the return value. If it is :string (the default), the substring of the specified submatch is returned. If it is :after or :before, the substring after or before the specified submatch is returned, respectively. If it is :index, a pair of (start . end) indexes are returned.

If the specified submatch isn't included in indexes, nil is returned.

A typical usage pattern of this function is like this:

(let ((r (multiple-value-list (match-re regexp string :return :index))))
  (re-submatch regexp string (cdr r) 3)))

Or, if you use the match object, like this:

(let ((match (match-re regexp string :return :match)))
  (re-submatch match nil nil 3))

The actual home package of this symbol is the regexp package. It is also exported from (and documented with) the excl package.

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


Copyright (c) 1998-2006, Franz Inc. Oakland, CA., USA. All rights reserved.
Documentation for Allegro CL version 7.0. This page is new in the 7.0 release.
Created 2005.9.20.

ToCDocOverviewCGDocRelNotesIndexPermutedIndex
Allegro CL version 7.0
This page is new in 7.0.