|
| Topics this page:
|
|
| GNU's regex package are available via ftp at ftp.gnu.org.
|
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Meta- character | Operator Name | Matches | Example regular expression |
|---|---|---|---|
|
|
period | any single character except NUL. | r.t would match the strings rat, rut, r t, but not root (two o's) nor the Rot in Rotten (upper case R). |
|
|
Kleene star, asterisk, wildcard | zero or more occurences of the character immediately preceding. | .* means match any number of any characters. |
|
|
dollar currency anchor | end of a line. | weasel$ would match the end of the string "He's a weasel" but not the string
"They are a bunch of weasels."
When the $ operator is the last operator of a regular expression or immediately follows a right parenthesis, it must be proceeded by a backslash \. |
|
|
circumflex or caret anchor | beginning of a string/line. | ^When in would match the beginning of the string "When in the course of human events" but would not match "What and When in the" . |
|
[c1-c2] [^c1-c2] |
square brackets | any one of the characters between the brackets. | r[aou]t matches rat, rot, and rut, but not ret. Ranges of characters can specified by using a hyphen. For example, the regular expression [0-9] means match any digit. Multiple ranges can be specified as well. The regular expression [A-Za-z] means match any upper or lower case letter. To match any character except those in the range, the complement range, use the caret as the first character after the opening bracket. For example, the expression [^269A-Z] matches any characters except 2, 6, 9, and upper case letters. |
|
|
caret within square brackets | the complement range -- any character except those in the range following the caret as the first character after the opening bracket. | [^269A-Z] will match any characters
except 2, 6, 9, and upper case letters.
When the ^ operator is the first operator of a regular expression or the first character inside brackets, it must be preceded by a backslash. |
|
|
back slash | This is the quoting character, use it to treat the following character
as an ordinary character. For example, \$ is used to match
the dollar sign character ($) rather than the end of a line. Similarly,
the expression \. is used to match the period character rather than any
single character.
Operators inside brackets do not need to be preceded by a backslash. | |
|
|
left slash and arrow | the beginning (\<) or end (\>) or a word. | \<the matches on "the" in the string "for the wise" but does not match "the" in "otherwise". NOTE: this metacharacter is not supported by all applications. |
|
|
left slash and parentheses | the expression between \( and \) as a group. | Also, saves the characters matched by the expression into temporary holding areas. Up to nine pattern matches can be saved in a single regular expression. They can be referenced as \1 through \9. |
|
|
pipe (alternation) | Or two conditions together. | (him|her) matches the line "it belongs to him" and matches the line "it belongs to her" but does not match the line "it belongs to them." NOTE: this metacharacter is not supported by all applications. |
|
|
plus sign | one or more occurences of the character or regular expression immediately preceding. | 9+ matches 9, 99, or 999. NOTE: this metacharacter is not supported by all applications. |
|
\ {i,j\} |
braces | a specific number of instances or instances within a range of the preceding character. | A[0-9]\{3\}
will match "A" followed by exactly 3 digits. That is, it will match A123
but not A1234.
[0-9]\{4,6\} matches any sequence of 4, 5, or 6 digits. NOTE: this metacharacter is supported by Robot's C-VU language but not by all applications. |
|
|
question mark | Matches 0 or 1 occurence of the character or regular expression immediately preceding. | ? is equivalent to {0,1}.
NOTE: this metacharacter is supported by |
In addition, VU regular expressions can include ASCII control characters in the range 0 to 7F hex (0 to 127 decimal).
|
|
|
|
|
|
regexlib.com provides a
|
|
Related:
| Your first name: Your family name: Your location (city, country): Your Email address: |
Top of Page Thank you! | |||