2 library(pcre): Perl compatible regular expression matching for SWI-Prolog
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog Regular Expression library
        • library(pcre): Perl compatible regular expression matching for SWI-Prolog
          • re_match/2
          • re_match/3
          • re_matchsub/4
          • re_foldl/6
          • re_split/3
          • re_split/4
          • re_replace/4
          • re_compile/3
          • re_flush/0
          • re_config/1
Availability::- use_module(library(pcre)).(can be autoloaded)
Source[semidet]re_match(+Regex, +String)
[semidet]re_match(+Regex, +String, +Options)
Succeeds if String matches Regex. For example:
?- re_match("^needle"/i, "Needle in a haystack").
true.

Options:

anchored(Bool)
If true, match only at the first position
bol(Bool)
Subject string is the beginning of a line (default false)
bsr(Mode)
If anycrlf, \R only matches CR, LF or CRLF. If unicode, \R matches all Unicode line endings. Subject string is the end of a line (default false)
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)
Subject string is the end of a line (default false)
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 and finally if crlf recognize CRLF as newline.
start(+From)
Start at the given character index
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 there 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)