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/3
          • re_matchsub/4
          • re_foldl/6
          • re_split/3
          • re_split/4
          • re_replace/4
          • re_replace/5
          • re_compile/3
          • re_flush/0
          • re_config/1
Availability::- use_module(library(pcre)).(can be autoloaded)
Source[det]re_split(+Pattern, +String, -Splits:list)
[det]re_split(+Pattern, +String, -Splits:list, +Options)
Split String using the regular expression Pattern. Splits is a list of strings holding alternating matches of Pattern and skipped parts of the String, starting with a skipped part. The Splits lists ends with a string of the content of String after the last match. If Pattern does not appear in String, Splits is a list holding a copy of String. This implies the number of elements in Splits is always odd. For example:
?- re_split("a+", "abaac", Splits, []).
Splits = ["","a","b","aa","c"].
?- re_split(":\\s*"/n, "Age: 33", Splits, []).
Splits = ['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).