- re_match(+Regex, +String) is semidet
- re_match(+Regex, +String, +Options) is semidet
- Succeeds if String matches Regex. For example:
?- re_match("^needle"/i, "Needle in a haystack"). true.
Defined Options are given below. For details, see the PCRE documentation. If an option is repeated, the first value is used and subsequent values are ignored. Unrecognized options are ignored. Unless otherwise specified, boolean options default to
false
.If Regex is a text pattern (optionally with flags), then any of the Options for re_compile/3 can be used, in addition to the Options listed below. If Regex is the result of re_compile/3, then only the following execution-time Options are recognized and any others are ignored. Some options may not exist on your system, depending on the PCRE2 version and how it was built - these unsupported options are silently ignored.
start(From)
Start at the given character indexanchored(Bool)
Iftrue
, match only at the first positionbol(Bool)
String is the beginning of a line (defaulttrue
) - affects behavior of circumflex metacharacter (^
).empty(Bool)
An empty string is a valid match (defaulttrue
)empty_atstart(Bool)
An empty string at the start of the subject is a valid match (defaulttrue
)eol(Bool)
String is the end of a line - affects behavior of dollar metacharacter ($
) (defaulttrue
).newline(Mode)
Ifany
, recognize any Unicode newline sequence, ifanycrlf
, recognize CR, LF, and CRLF as newline sequences, ifcr
, recognize CR, iflf
, recognize LF, ifcrlf
recognize CRLF as newline. The default is determined by how PCRE was built, and can be found byre_config(newline2(NewlineDefault))
.newline2(Mode)
- synonym fornewline(Mode)
.utf_check(Bool)
- see PCRE2 API documentation You should not need this because SWI-Prolog ensures that the UTF8 strings are valid, so the default isfalse
.endanchored(Bool)
- see PCRE2 API documentationpartial_soft(Bool)
- see PCRE2 API documentationpartial_hard(Bool)
- see PCRE2 API documentationdfa_restart(Bool)
- see PCRE2 API documentationdfa_shortest(Bool)
- see PCRE2 API documentation
- Arguments:
-
Regex - is the output of re_compile/3, a pattern or a term Pattern/Flags, where Pattern is an atom or string. The defined flags and their related option for re_compile/3 are below. - x:
extended(true)
- i:
caseless(true)
- m:
multiline(true)
- s:
dotall(true)
- a:
capture_type(atom)
- r:
capture_type(range)
- t:
capture_type(term)
If Regex is the output of re_compile/3, any compile-time options in Options or Flags are ignored and only match-time options are used.
The options that are derived from flags take precedence over the options in the Options list. In the case of conflicting flags, the first one is used (e.g.,
ra
results incapture_type(range)
). - x: