SICStus Prolog interface to ISO regular expression functions
Straightforward SICStus Prolog interface to the ISO regular expression
functions
regcomp(3),
regexec(3),
regfree(3),
regerror(3). Tested with HP-UX 10.20 (cc) and Linux 2.0
(gcc). You need at least SICStus 3 #5.
Sources
Yes, here.
Copyright
Copyright is
GPL.
Install
check the Makefile. You have to make sure that the program finds
appropriate regex.h. If regular expression functions are not in
standard library, then you need to add the library with the +l option
to splfr. For HP-UX 10.20 and Linux 2.0 you don't have to do anything.
Predicates
- regmatch(+Pattern,+String)
succeeds if the pattern occurs somewhere within String
both arguments are lists of character codes.
- regmatch(+Pattern,+String,-ListOfStrings)
returns the list of substrings in String matching
the sub-patterns in Pattern. The first substring
is the string matched by the pattern as a whole.
If ListOfStrings is the empty list, then the pattern didn't
match.
First two arguments are lists of character codes; third argument
is a list of list of character codes.
- regmatch(+Pattern,+String,-ListOfStrings,+CFlags,+EFlags)
returns the list of substrings in String matching
the sub-patterns in Pattern. The first substring
is the string matched by the pattern as a whole.
If ListOfStrings is the empty list, then the pattern didn't
match.
The first two arguments are lists of character codes. The third
argument is a list of lists of character codes.
Cflags is a list of atoms from
{reg_extended,reg_newline,reg_icase,reg_nosub}. These relate
straightforwardly to the flags accepted by regcomp(3).
Eflags is a list of atoms from
{reg_notbol,reg_noteol}. These relate straightforwardly to
the flags accepted by regexec(3).
- regcomp(+PatternString,-CompiledPattern)
compiles the pattern given as a list of charactercodes in
PatternString into a compiled pattern. You are responsible
for freeing the space occupied by CompiledPattern, using
regfree at the appropriate moment.
The first argument is a list of character codes, the second
argument is an address.
- regcomp(+PatternString,-CompiledPattern,+Cflags)
compiles the pattern given as a list of charactercodes in
PatternString into a compiled pattern. You are responsible
for freeing the space occupied by CompiledPattern, using
regfree at the appropriate moment.
The first argument is a list of character codes, the second
argument is an address.
Cflags is a list of atoms from
{reg_extended,reg_newline,reg_icase,reg_nosub}. These relate
straightforwardly to the flags accepted by regcomp(3)
- regfree(+CompiledPattern)
frees the space occupied by CompiledPattern. You should not
use CompiledPattern after that. The argument is an address.
- regexec(+String,+CompiledPattern)
succeeds if the pattern occurs somewhere within String.
CompiledPattern is a compiled pattern created using regcomp.
First argument is list of character codes. Second argument is
an address.
- regexec(+String,+CompiledPattern,-ListOfStrings)
returns the list of substrings in String matching
the sub-patterns in CompiledPattern. The first substring
is the string matched by the pattern as a whole.
If ListOfStrings is the empty list, then the pattern didn't
match. CompiledPattern is a pattern created using regcomp.
The first argument is a list of character codes. The second
argument is an address. The third argument is a list of lists
of character codes.
- regexec(+String,+CompiledPattern,-ListOfStrings,+Eflags)
returns the list of substrings in String matching
the sub-patterns in CompiledPattern. The first substring
is the string matched by the pattern as a whole.
If ListOfStrings is the empty list, then the pattern didn't
match. CompiledPattern is a pattern created using regcomp.
The first argument is a list of character codes. The second
argument is an address. The third argument is a list of lists
of character codes.
Eflags is a list of atoms from
{reg_notbol,reg_noteol}. These relate straightforwardly to
the flags accepted by regexec(3).
Others
for other approaches refer to