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[det]re_split(+Pattern, +String, -Split:list)
[det]re_split(+Pattern, +String, -Split:list, +Options)
Split String using the regular expression Pattern. Split is a list of strings holding alternating matches of Pattern and skipped parts of the String, starting with a skipped part. The Split lists ends with a string of the content of String after the last match. If Pattern does not appear in String, Split is a list holding a copy of String. This implies the number of elements in Split is always odd. For example:
?- re_split("a+", "abaac", Split, []).
Split = ["","a","b","aa","c"].
?- re_split(":\\s*"/n, "Age: 33", Split, []).
Split = ['Age', ': ', 33].
Pattern is the pattern text, optionally follows by /Flags. Similar to re_matchsub/4, the final output type can be controlled by a flag a (atom), s (string, default) or n (number if possible, atom otherwise).