Ok, for the Regular Exp
ressions as implemented (intended):
$x = RegExp($line, $pattern [,"Array"])Perform a case-sensitive comparison of
$line against the given pattern. Both are to be strings.
The pattern is defined using the following symbols:
- "abc" - all regular characters that match themselves. i.e. match abc somewhere in the string.
- "[abc]" - set: match one character that is a, b or c somewhere in the string
- "[^abc]" - negated set: match one character other than a, b or c.
- "b*" - matches 0 or more b's.
- "b+" - matches 1 or more b's.
- "b?" - optional: matches b if it is there, but does not have to be.
- "^abc" - abc must appear at the beginning of the string.
- "abc$" - abc must appear at the end of the string.
- "(abc)" - group: treat the pattern inside the brackets as a unit. e.g. "(ab)+" matches "ab", "abab", "ababab", etc. The text that matches a group will be stored in the array if it is named in the RegExp call.
I am also including a whole bunch of class definitions: \s for any one whitespace, \d for any one digit, \a for any one alphabetic character, \A for any one alphanumeric character, \p for any punctuation character, \w for any word character (alphabetic or underline), \u for any upper-case character, \l (lower L) for any lower-case character. I think I have them all.
That what the docs are for. Man, was writing the docs a pain. Oh well, one of the necessary evils of writing a program is documenting it.
I have also written a function to keep track of regular exp
ressions that you use repeatedly:
RegExpSet and
RegExpClose. RegExpSet interprets and stores the regular exp
ression and returns a handle, similar to FileOpen. Do not mix up FileOpen handles and RegExpSet handles! They are not the same! You can replace the $pattern in the above function call with a handle given by RegExpSet. RegExpClose releases the memory that was used by the stored regular exp
ression.
Using RegExpSet will speed up calls of RegExp because the pattern does not have to be interpreted each time, but only once. I only made 4 spaces to store regular exp
ressions. Do people think that is enough?
Edit: Fix spelling errors.
Edited by Nutster, 29 October 2004 - 04:54 PM.