Module "text"
The predicates code_class/2 and char_class/2 can be used to
classify a character. The char-acter classifier is configurable
and plug-able. To use a custom character classifier the
predi-cates code_class/3 and char_class/3 can be used. The
predicates code_digit/3 and char_digit/3 can be used to classify
and decode digits in a given base.
Examples:
?- char_class(a, X).
X = lower
?- char_class('A', X).
X = upper
The default character classifier uses the Prolog ISO core
standard classification for the ASCII range plus the Jekejeke
Prolog specific extension for Unicode. The predicates code_lower/2
and code_upper/2 can be used for case conversion of code points.
The predicates downcase_atom/2 and upcase_atom/2 can be used for
case conversion of atoms.
Examples:
?- pattern_match('foobarfoo','bar').
No
?- pattern_match('foobarfoo','*bar*').
Yes
We also provide predicates for pattern matching. The predicate
pattern_match/2 takes an atom and matches it against a pattern.
The predicate pattern_replace/4 takes a further pattern and
produces a new atom. The pattern language provided by us is
inspired by the former NEBIS library system.
The following text predicates are provided:
- char_class(C, N):
- char_class(H, C, N):
- The predicate succeeds for the name N of the Prolog
classification of the character C. The ternary predicate allows
specifying a custom classifier H. The following classification
names are currently supported:
- blank: The character is a blank space.
- cntrl: The character is a control character.
- inval: The character is invalid.
- solo: The character is a solo character.
- score: The character is an underscore.
- upper: The character is an upper case letter.
- lower: The character is a lower case letter.
- other: The character is some other alpha numerical
character.
- digit: The character is a decimal digit.
- symbol: The character is a symbol character.
- code_class(C, N):
- code_class(H, C, N):
- The predicate succeeds for the name N of the Prolog
classification of the code point C. The ternary predicate allows
specifying a custom classifier H.
- char_digit(C, R, V):
- The predicate succeeds in V with the numerical value of the
digit C in the radix R.
- code_digit(C, R, V):
- The predicate succeeds in V with the numerical value of the
digit C in the radix R.
- code_lower(C, D):
- The predicate succeeds in D for the lower case of C.
- code_upper(C, D):
- The predicate succeeds in D for the upper case of C.
- downcase_atom(A, B): [Prolog Commons Atom Utilities]
- The predicate succeeds in B for the lower case of A.
- upcase_atom(A, B): [Prolog Commons Atom Utilities]
- The predicate succeeds in B for the upper case of AB.
- pattern_match(S, P):
- pattern_match(S, P, O):
- The predicate succeeds when the atom S matches the shell
pattern P. The ternary predicate allows specifying match options
O. The following match options are currently supported:
- boundary(B): B is the pattern boundary condition.
- ignore_case(I): I is the ignore case flag.
- style(S): S is the style.
The legal values for the pattern boundary condition are whole,
part and word. The default value is whole. The legal values for
the ignore case flag are true and false. The default value is
false. The legal values for the style are create and parse. The
default value is create.
- pattern_replace(S, P, R, T):
- pattern_replace(S, P, R, T, O):
- The predicate succeeds when the atom S matches the shell
pattern P, and when re-placing the matched pattern by R yields
the atom T. The quinary predicate allows specifying match and
replaces options O.
- last_pattern_replace(S, P, R, T):
- last_pattern_replace(S, P, R, T, O):
- These predicates work similar to the predicates replace/4 and
replace/5 except that they search backwards.
Kommentare