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 index
anchored(Bool)
If true
, match only at the
first position
bol(Bool)
String is the beginning of a line (default true
)
- affects behavior of circumflex metacharacter (^
).
empty(Bool)
An empty string is a valid match (default true
)
empty_atstart(Bool)
An empty string at the start of the
subject is a valid match (default true
)
eol(Bool)
String is the end of a line - affects behavior of dollar
metacharacter ($
) (default true
).
newline(Mode)
If any
, recognize any
Unicode newline sequence, if anycrlf
, recognize CR, LF, and
CRLF as newline sequences, if cr
, recognize CR, if lf
,
recognize LF, if crlf
recognize CRLF as newline. The
default is determined by how PCRE was built, and can be found by re_config(newline2(NewlineDefault))
.
newline2(Mode)
- synonym for newline(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 is false
.
endanchored(Bool)
- see PCRE2
API documentation
partial_soft(Bool)
- see PCRE2
API documentation
partial_hard(Bool)
- see PCRE2
API documentation
dfa_restart(Bool)
- see PCRE2
API documentation
dfa_shortest(Bool)
- see PCRE2
API documentation
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 in capture_type(range) ). |