[ library(regex) | The ECLiPSe Libraries | Reference Manual | Alphabetic Index ]

matchsub(+Pattern, +String, +Options, -SubMatches)

A substring of String matches the regular expression Pattern and SubMatches are matching sub-expressions
Pattern
A string (or a compiled pattern handle)
String
A string
Options
List of atoms
SubMatches
Output: List of strings

Description

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

Fail Conditions

String does not match Pattern

Examples

    ?- matchsub("Name:([^,]+), Age:([0-9]+),", "Name:Fred, Age:34,", [], L).
    L = ["Fred", "34"]
    Yes
    

See Also

library(regex), match / 2, match / 3, match / 4, compile_pattern / 3