regexp_code (library)

Usage and interface

Documentation on exports

PREDICATE

Usage:match_shell(Exp,IN,Rest)

Matches IN against Exp. Rest is the longest remainder of the string after the match. For example, match_shell("??*","foo.pl",Tail) succeeds, instantiating Tail to "o.pl".

  • The following properties should hold at call time:
    (regexp_code:shell_regexp/1)Exp is a shell regular expression to match against.
    (regexp_code:string/1)IN is a string.
    (regexp_code:string/1)Rest is a string.

PREDICATE

Usage:match_shell(Exp,IN)

Matches completely IN (no tail can remain unmatched) against Exp similarly to match_shell/3.

  • The following properties should hold at call time:
    (regexp_code:shell_regexp/1)Exp is a shell regular expression to match against.
    (regexp_code:string/1)IN is a string.

PREDICATE

Usage:match_posix(Exp,IN)

Matches completely IN (no tail can remain unmatched) against Exp similarly to match_posix/3.

  • The following properties should hold at call time:
    (regexp_code:shell_regexp/1)Exp is a shell regular expression to match against.
    (regexp_code:string/1)IN is a string.

PREDICATE

Usage:match_posix(Exp,In,Match,Rest)

  • The following properties should hold at call time:
    (regexp_code:shell_regexp/1)Exp is a shell regular expression to match against.
    (regexp_code:string/1)In is a string.
    (basic_props:list/2)Match is a list of strings.
    (regexp_code:string/1)Rest is a string.

PREDICATE

Usage:match_posix_rest(Exp,IN,Rest)

Matches IN against Exp. Tail is the remainder of the string after the match. For example, match_posix("ab*c","abbbbcdf",Tail) succeeds, instantiating Tail to "df".

  • The following properties should hold at call time:
    (regexp_code:posix_regexp/1)Exp is a posix regular expression to match against.
    (regexp_code:string/1)IN is a string.
    (regexp_code:string/1)Rest is a string.

PREDICATE

Usage:match_posix_matches(Exp,IN,Matches)

Matches completely IN against Exp. Exp can contain anchored expressions of the form \(regexp\). Matches will contain a list of the anchored expression which were matched on success. Note that since POSIX expressions are being read inside a string, backslashes will have to be doubled. For example,

?- match_posix_matches("\\(aa|bb\\)\\(bb|aa\\)", "bbaa", M).
M = ["bb","aa"] ? ;
no

?- match_posix_matches("\\(aa|bb\\)\\(bb|aa\\)", "aabb", M).
M = ["aa","bb"] ? ;
no

  • The following properties should hold at call time:
    (regexp_code:shell_regexp/1)Exp is a shell regular expression to match against.
    (regexp_code:string/1)IN is a string.
    (basic_props:list/2)Matches is a list of strings.

PREDICATE

Usage:match_struct(Exp,IN,Rest,Tail)

Matches IN against Exp. Tail is the remainder of the list of atoms IN after the match. For example, match_struct([a,*(b),c],[a,b,b,b,c,d,e],Tail) succeeds, instantiating Tail to [d,e].

  • Call and exit should be compatible with:
    (regexp_code:struct_regexp/1)Exp is a struct regular expression to match against.
    (regexp_code:string/1)IN is a string.
    (regexp_code:string/1)Rest is a string.

PREDICATE

Usage:match_pred(Pred1,Pred2)

Tests if two predicates Pred1 and Pred2 match using posix regular expressions.

    PREDICATE

    Usage:replace_first(IN,Old,New,Resul)

    Replace the first ocurrence of the Old by New in IN and copy the result in Resul.

    • The following properties should hold at call time:
      (regexp_code:string/1)IN is a string.
      (regexp_code:posix_regexp/1)Old is a posix regular expression to match against.
      (regexp_code:string/1)New is a string.
      (regexp_code:string/1)Resul is a string.

    PREDICATE

    Usage:replace_all(IN,Old,New,Resul)

    Replace all ocurrences of the Old by New in IN and copy the result in Resul.

    • The following properties should hold at call time:
      (regexp_code:string/1)IN is a string.
      (regexp_code:posix_regexp/1)Old is a posix regular expression to match against.
      (regexp_code:string/1)New is a string.
      (regexp_code:string/1)Resul is a string.

    REGTYPE

    Usage:shell_regexp(P)

    P is a shell regular expression to match against.

      REGTYPE

      Usage:posix_regexp(P)

      P is a posix regular expression to match against.

        REGTYPE

        Usage:struct_regexp(P)

        P is a struct regular expression to match against.

          Documentation on multifiles

          PREDICATE

          (Trust) Usage:define_flag(Flag,FlagValues,Default)

          • The following properties hold upon exit:
            (basic_props:atm/1)Flag is an atom.
            (basic_props:flag_values/1)Define the valid flag values
          The predicate is multifile.