NAME

/precompiled/regexp - regexp handling module

DESCRIPTION

/precompiled/regexp is a precompiled LPC program that interfaces a regexp package written in C. It contains a few simple functions to handle regexps. A short description of regexp follows:

.
Matches any character
[abc]
Matches a, b or c
[a-z]
Matches any character a to z inclusive
[^ac]
Matches any character except a and c
(x)
Matches x (x might be any regexp) If used with split, this
also puts the string matching x into the result array.
x*
Matches zero or more occurances of 'x' (x may be any regexp)
x+
Matches one or more occurances of 'x' (x may be any regexp)
x|y
Matches x or y. (x or y may be any regexp)
xy
Matches xy (x and y may be any regexp)
^
Matches beginning of string (but no characters)
$
Matches end of string (but no characters)
\<
matches the beginning of a word (but no characters)
\>
matches the end of a word (but no characters)

Note that \ can be used to quote these characters in which case they match themselves, nothing else. Also note that when quoting these something in uLPC you need two \ because uLPC also uses this character for quoting.

For more information about regexps, refer to your unix manuals such as sed or ed.

Descriptions of all functions in /precompiled/regexp follows:


NAME

create - compile regexp

SYNTAX

void create();
or
void create(string regexp);
or
object clone((program)"/precompiled/file");
or
object clone((program)"/precompiled/file",string regexp);

DESCRIPTION

When create is called, the current regexp bound to this object is cleared. If a string is sent to create(), this string will be compiled to an internal representation of the regexp and bound to this object for laters calls to match or split. Calling create() without an argument can be used to free up a little memory after the regexp has been used.

SEE ALSO

clone and regexp->match


NAME

match - match a regexp

SYNTAX

int regexp->match(string s)

DESCRIPTION

Return 1 if s matches the regexp bound to the object regexp, zero otherwise

SEE ALSO

regexp->create and regexp->split


NAME

split - split a string according to a pattern

SYNTAX

string *regexp->split(string s)

DESCRIPTION

Works as regexp->match, but returns an array of the strings that matched the subregexps. Subregexps are those contained in ( ) in the regexp. Subregexps that were not matched will contain zero. If the total regexp didn't match, zero is returned.

BUGS

You can only have 40 subregexps.

SEE ALSO

regexp->create and regexp->split