A .NET online regex tester: http://regexstorm.net/tester
RexEgg is a site containing black belt stuff concerning regexes and also a regex cheat sheet.
Another site containing fine info about Regexes.
One more, called Regextutorial.
Shorthands for character classes and anchors
| Regex | What it Matches | Inversion |
|---|---|---|
| \d | [0-9] or with Unicode all digits. Not in AWK. | \D |
| \w | [A-Za-z0-9_] or with Unicode all word characters | \W |
| \s | [ \t\r\n\f] or all whitespace | \S |
| \b, AWK and Tcl:\y | Matches the boundary at the start or end of a word. Is \y in AWK and Tcl as there \b means backspace. | \B, Tcl: \Y |
Some specialties
All of these specialties do not work in AWK nor in GAWK. They do work in Perl, probably.
| Regex | Name | What it Does |
|---|---|---|
| (?:bar) | non-capturing | Matches bar, but doesn’t capture it. |
| (?=foo) | lookahead | Asserts that what immediately follows the current position in the string is foo. |
| (?<=bar) | lookbehind | Asserts that what immediately precedes the current position in the string is bar. |
| (?!baz) | negative lookahead | Asserts that what immediately follows the current position in the string is not baz. |
| (?<!foo) | negative lookbehind | Asserts that what immediately precedes the current position in the string is not foo. Usage: (?<!wgruppe.*)"8" only finds those cases of "8" which are not preceded by wgruppe anywhere. |
| (?i) | case-insensitive | Turns on case-insensitive matching. Not in AWK. AWK has no really short way to match case-insensitive. One can use BEGIN{IGNORECASE=1} as starting block or tolower($0)~/abc/ instead of /abc/ |
| (?m) | multi-line | Turns on multi-line mode. $ and ^ match at any line, not only at begin and start of text. Not in AWK. |
| (?x) | comment | Activates comment-mode. Whitespace is ignored and a # in a line starts a comment. Not in AWK. |
| \b AWK:\y | word boundary | Matches the boundary at the start or end of a word. \y in AWK as there \b means backspace. |
| (?<g>xi) | named group | Matches xi and gives the capture group the name g. Access to group in code: m.groups["g"]. Only in .NET like this. Some other systems have other possibilities for named groups. |