[ library(regex) | Reference Manual | Alphabetic Index ]
matchsub(+Pattern, +String, +Options, -SubMatches)
A substring of String matches the regular expression Pattern and SubMatches are matching sub-expressions
- A string (or a compiled pattern handle)
- A string
- List of atoms
- Output: List of strings
Succeeds if all or a substring of String matches the regular
expression Pattern. For the description of regular expressions
see the library(regex) page.
Options is a (possibly empty) list of atomic option names,
as described in the library(regex) page.
SubMatches is bound to a list of strings, each corresponding to
a parenthesized subexpression in Pattern. These subexpressions
are ordered according to the position of their opening parenthesis
within the pattern. The matching string appears on the corresponding
position in the SubMatches list. Note that, if a subexpression matches
several times, only the last match is returned.
Modes and Determinism
- matchsub(+, +, +, -) is semidet
String does not match Pattern
?- matchsub("Name:([^,]+), Age:([0-9]+),", "Name:Fred, Age:34,", , L).
L = ["Fred", "34"]
library(regex), match / 2, match / 3, match / 4, compile_pattern / 3