Regular Expressions
Simple matches:
Any single character matches itself, unless it is a metacharacter with a special meaning described below. You can cause characters that normally function as metacharacters or escape sequences to be interpreted literally by "escaping" them by preceding them with a backslash "\", for instance: metacharacter "^" match beginning of string, but "\^" match character "^", "\\" match "\" and so on.foobar | - matchs string "foobar" |
\^FooBarPtr | - matchs "^FooBarPtr" |
Escape sequences:
Characters may be specified using a escape sequences syntax much like that used in C and Perl: "\n" matches a newline, "\t" a tab, etc. More generally, "\xnn", where "nn" is a string of hexadecimal digits, matches the character whose ASCII value is nn. If You need wide (Unicode) character code, You can use "\x{nnnn}", where "nnnn" - one or more hexadecimal digits.foo\x20bar | - matchs "foo bar" (note space in the middle) |
\tfoobar | - matchs "foobar" predefined by tab |
Character classes:
You can specify a character class, by enclosing a list of characters in [], which will match any one character from the list. If the first character after the "[" is "^", the class matches any character not in the list. Within a list, the "-" character is used to specify a range, so that a-z represents all characters between "a" and "z", inclusive.foob[aeiou]r | - finds strings "foobar", "foober" etc. but not "foobbr", "foobcr" etc. |
foob[^aeiou]r | - find strings "foobbr", "foobcr" etc. but not "foobar", "foober" etc. |
[-az] | - matchs "a", "z" and "-" |
[a\-z] | - matchs "a", "z" and "-" |
[a-z] | - matchs all twenty six small characters from "a" to "z" |
[\n-\x0D] | - matchs any of #10,#11,#12,#13. |
[^0-9] | - matchs any none digit character |
Predefined Classes:
\w | an alphanumeric character (including "_") |
\W | a nonalphanumeric |
\d | a numeric character |
\D | a non-numeric |
\s | any space (same as [ \t\n\r\f]) |
\S | a non space |
Word Boundaries:
\b | Match a word boundary |
\B | Match a non-(word boundary) |
Iterators:
* | zero or more ("greedy"), similar to {0,} |
+ | one or more ("greedy"), similar to {1,} |
? | zero or one ("greedy"), similar to {0,1} |
{n} | exactly n times ("greedy") |
{n,} | at least n times ("greedy") |
{n,m} | at least n but not more than m times ("greedy") |
*? | zero or more ("non-greedy"), similar to {0,}? |
+? | one or more ("non-greedy"), similar to {1,}? |
?? | zero or one ("non-greedy"), similar to {0,1}? |
{n}? | exactly n times ("non-greedy") |
{n,}? | at least n times ("non-greedy") |
{n,m}? | at least n but not more than m times ("non-greedy") |
Special Symbols:
| | specifies a series of alternatives for a pattern |
$n | subexpression n, starts from "1" and "0" is the whole expression |
Complex Examples:
More Information:
www.regexpstudio.com