"SfR Fresh" - the SfR Freeware/Shareware Archive

Member "tutorial/wipeout-tut11.html" of archive wipeout-tut-1.5.4.tar.gz:


Caution: In this restricted "SfR Fresh" environment the current HTML page may not be correctly presentated and may have some non-functional links. Alternatively you can here view or download the uninterpreted source code. That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.

11. An Overview of Regular Expressions

Regular expressions are used to determine if some string matches have particular expression. There are many different implementations of such regular expressions, the following table explains the regular expressions of WIPEOUT.

char matches itself, unless it is a special character: . \ [ ] ^ * + ?
. matches any character, but not \n
[set] matches one of the characters in set. If the first character in the set is '^', it matches a character not in the set. A short 'a-z' is used to to define a set of characters 'a' up to 'z'.
\ matches the character following it, except when followed by a left or right round bracket, an angle bracket, a '|' or one of the characters "ntr" (see below for that). It is used as an escape character for all other special characters and itself. When used in a set it is treated as an ordinary character
* any regular expression followed by '*' matches zero, one or more times of that form
+ any regular expression followed by '+' matches one or more times of that form
? any regular expression followed by '?' matches zero or once of that form
\n, \t, \r these are used in regular expressions to denote the special characters newline, tab and carriage return
\( \) any regular expression enclosed as \(expression\) matches what expression matches. With these meta characters you can overwrite the precedences rules of repetitions.
\| any expression joined like "exp1\|exp2" matches any string matching either subexpression (exp1 or exp2)
\< \>
This is an extension to GNU regex. It is not compatible to the GNU implementation!
These meta characters allows you to define case insensitive regular expressions, so you don't have to give each combination of possible regular expressions.

The next table shows some examples to illustrate the use of regular expressions in WIPEOUT.

a finds the character 'a'
a. finds 'ab', 'ax' or the concatenation of 'a' and any character
a+ finds 'a', 'aa', 'aaaa' (any amount of 'a' but at least one)
a* finds any amount of 'a'
[ab] finds one of the characters 'a' or 'b'
[A-Z] finds an upper letter
[0-9] finds a digit
[^a-zA-Z] finds a character that is not a letter
ho.e finds 'home' and 'hole' but not 'horse'
ho.?e finds 'home' and 'hole' and 'hoe'
\(a\|bc\|d\) finds 'a' or 'bc' or 'd'
\(a\|b\)\(c\|d\) finds 'ac' or 'ad' or 'bc' or 'bd'
\<FUNCTION\> finds any occurrence of the string "function", what can be "Function", "fUNCTION" and so on


Previous Up Contents Next