regexp_code (library)
Usage and interface
- Library usage:
:- use_module(library(regexp_code)). - Exports:
- Predicates:
match_shell/3, match_shell/2, match_posix/2, match_posix/4, match_posix_rest/3, match_posix_matches/3, match_struct/4, match_pred/2, replace_first/4, replace_all/4. - Regular Types:
shell_regexp/1, posix_regexp/1, struct_regexp/1. - Multifiles:
define_flag/3.
- Predicates:
- Imports:
- System library modules:
lists. - Packages:
prelude, nonpure, assertions, dcg, regtypes, define_flag.
- System library modules:
Documentation on exports
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.
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.
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.
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.
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.
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.
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.
Usage:match_pred(Pred1,Pred2)
Tests if two predicates Pred1 and Pred2 match using posix regular expressions.
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.
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.
Documentation on multifiles
(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