Tools
Regular Expression Tester
This web page validates regular expression patterns against test input. You can even validate a pattern against multiple input lines simoultaneously, if you check off global match and multiline. I find this useful for URI rewrite testing, when you wish to match multiple URI's with a single pattern.
Note: this implementation is based on the JavaScript implementation of RegExp so lookbehind assertions are not supported.
| Sample patterns |
| ^\w+([-+.']\w+)*@\w+([-.]\w+)*\.[a-zA-Z]{2,6}$ |
E-mail address, e.g. "[email protected]" |
Test |
| ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$ |
IPv4 address, e.g. "123.123.123.123" |
Test |
| ^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9-]*[A-Za-z0-9])$ |
Host name, e.g. "ole.michelsen.dk" |
Test |
| ^(.*/)?(?:$|(.+?)(?:(\.[^.]*$)|$)) |
Path, e.g. "/path/to/file.ext" |
Test |
| Special Characters |
| \ | Escape Character |
| \n | New line |
| \r | Carriage return |
| \t | Tab |
| \v | Vertical tab |
| \f | Form feed |
| Meta Characters (must be escaped) |
| ^ | [ | . | $ | { |
| * | ( | ) | + | \ |
| | | ? | < | > | |
| Character Classes |
| \w | Word (a-z, A-Z, 0-9, including _ (underscore)) |
| \W | Non-word |
| \d | Digit (0-9) |
| \D | Non-digit |
| \s | Whitespace |
| \S | Not whitespace |
| \b | Match at beginning or end |
| \B | Do not match at beginning or end |
| \0 | NUL character |
| \n | New line |
| Quantifiers |
| n* | 0 or more n |
| n*? | 0 or more n, ungreedy |
| n+ | 1 or more n |
| n+? | 1 or more n, ungreedy |
| n? | 0 or 1 n |
| n?? | 0 or 1 n, ungreedy |
| n{2} | Exactly 2 n |
| n{2,} | 2 or more n |
| n{2,4} | 2, 3 or 4 n |
| n{2,4}? | 2, 3 or 4 n, ungreedy |
| Anchors |
| ^ | Start of line |
| $ | End of line |
| Assertions |
| n(?=o) | Lookahead, n followed by o (not matching o) |
| n(?!o) | Negative lookahead, n not followed by o (not matching o) |
| (?<=o)n | Lookbehind, o preceding n |
| (?<!o)n | Negative lookbehind, o not preceding n |
| Ranges |
| . | Any character except new line (\n) |
| (a|b) | a or b |
| (...) | Group |
| (?:...) | Passive Group |
| [abc] | Range (a, b or c) |
| [^abc] | Not a, b or c |
| [a-z] | Character between a and z, lower case |
| [A-Z] | Character between A and Z, upper case |
| [0-9] | Number between 0 and 9 |
| [a-zA-Z0-9] | Characters between a and z (both cases), and numbers between 0 and 9 |
| \n | nth group/subpattern |