Go to the first, previous, next, last section, table of contents.
Author(s): The CLIP Group.
Version: 1.11#222 (2004/5/24, 13:8:7 CEST)
Version of last change: 1.11#133 (2003/12/30, 23:32:28 CET)
This library provides facilities for matching strings and terms against
patterns (i.e.,
regular expressions).
- Library usage:
:- use_module(library(patterns)).
- Exports:
- Predicates:
match_pattern/2
,
match_pattern/3
,
case_insensitive_match/2
,
letter_match/2
,
match_pattern_pred/2
.
- Regular Types:
pattern/1
.
- Other modules used:
- System library modules:
lists
.
- PREDICATE: match_pattern/2:
-
Usage: match_pattern(Pattern, String)
- Description: Matches
String
against Pattern
. For example, match_pattern("*.pl","foo.pl")
succeeds.
- The following properties should hold at call time:
Pattern
is a pattern to match against.
(patterns:pattern/1
)
String
is a string (a list of character codes).
(basic_props:string/1
)
- PREDICATE: match_pattern/3:
-
Usage: match_pattern(Pattern, String, Tail)
- Description: Matches
String
against Pattern
. Tail
is the remainder of the string after the match. For example, match_pattern("??*","foo.pl",Tail)
succeeds, instantiating Tail
to "o.pl"
.
- The following properties should hold at call time:
Pattern
is a pattern to match against.
(patterns:pattern/1
)
String
is a string (a list of character codes).
(basic_props:string/1
)
Tail
is a string (a list of character codes).
(basic_props:string/1
)
- PREDICATE: case_insensitive_match/2:
-
Usage: case_insensitive_match(Pred1, Pred2)
- Description: Tests if two predicates
Pred1
and Pred2
match in a case-insensitive way.
- PREDICATE: letter_match/2:
-
Usage: letter_match(X, Y)
- Description: True iff
X
and Y
represents the same letter
- REGTYPE: pattern/1:
-
Special characters for Pattern
are:
- *
-
Matches any string, including the null string.
- ?
-
Matches any single character.
- [...]
-
Matches any one of the enclosed characters. A pair of characters separated by a minus sign denotes a range; any character lexically between those two characters, inclusive, is matched. If the first character following the [ is a ^ then any character not enclosed is matched. No other character is special inside this construct. To include a ] in a character set, you must make it the first character. To include a `-', you must use it in a context where it cannot possibly indicate a range: that is, as the first character, or immediately after a range.
- |
-
Specifies an alternative. Two patterns A and B with | in between form an expression that matches anything that either A or B will match.
- {...}
-
Groups alternatives inside larger patterns.
- \
-
Quotes a special character (including itself).
Usage: pattern(P)
- Description:
P
is a pattern to match against.
- PREDICATE: match_pattern_pred/2:
-
Usage: match_pattern_pred(Pred1, Pred2)
- Description: Tests if two predicates
Pred1
and Pred2
match using regular expressions.
Go to the first, previous, next, last section, table of contents.