MGI Regular Expressions

Syntax

MGI supports UNIX extended regular expression syntax. The syntax for regular expression symbols are:

Symbol Function
\ Marks the next character as a special escaped character
^ Matches/anchors the beginning of line
$ Matches/anchors the end of line
? Matches the preceding pattern or group zero or one times
* Matches the preceding pattern or group zero or more times
+ Matches the preceding pattern or group one or more times
. Matches any single character except \r and \n
{x,y} Matches the preceding pattern at least x times, no more than y times
b{7} Matches exactly 7 characters
b{7,} Matches at least 7 characters
b{7,9} Matches at least 7 characters but no more than 9 characters
(expression) Brackets or tags an expression as a group (there may be up to 9 groups)
abc|xyz Matches abc OR xyz
(abc|xyz) Matches abc OR xyz
[xyz] A character set. Matches any characters between brackets
[^xyz] A negative character set. Matches any characters NOT between brackets
\f Matches a form-feed character
\n Matches a linefeed character
\r Matches a carriage return character
\t Matches a tab character
\v Matches a vertical tab character
\c Matches a character. Equivalent to [A-Za-z]
\C Matches a noncharacter. Equivalent to [^A-Za-z]
\d Matches a digit. Equivalent to [0-9]
\D Matches a nondigit. Equivalent to [^0-9]
\s Matches any white space including space, tab, formfeed, etc but not newline.
Equivalent to [ \f\t\v]
\S Matches any nonwhite space character but not newline.
Equivalent to [^ \f\t\v]
\w Matches any word character including underscore.
Equivalent to [A-Za-z0-9 _]
\W Matches any nonword character.
Equivalent to [^A-Za-z0-9 _]

Note - ^ refers to the character '^' NOT Control Key + value

Special Character Requirements:

To search for a '[' place it inside a character set or escape it with a backslash
To search for a ']' it must be the first character inside the character set or escaped with a backslash
To search for .,+*?$(){} they must be inside a character set or escaped with a backslash
To search for '^' it must not be the first character on a line or the first character in a set or it must be escaped with a backslash
To search for '-' in a character set it must be first or last character in the set


Example Usage and Output

m.n matches "man", "men", "min" but not "moon"
Te?st matches "tst", "test" BUT NOT "teest", "teeest" etc.
Te+st matches "test", "teest", "teeeest" etc. BUT NOT "tst"
Te*st matches "test", "teest", "teeeest" etc. AND "tst"
[aeiou] matches every lowercase vowel
[,.?] matches a literal ",", "." or "?"
[0-9a-z] matches any digit, or lowercase letter
[^0-9] matches any character except a digit (^ means NOT the following)
You may search for an expression A or B as follows: (John|Jane)


[Understanding MGI Menu] [Using MGI Menu] [Referencing MGI Menu]


[MGI Guides Main Menu] [User Guide Main Menu]