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. "" 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. "" Test
^(.*/)?(?:$|(.+?)(?:(\.[^.]*$)|$)) Path, e.g. "/path/to/file.ext" Test

Special Characters
\Escape Character
\nNew line
\rCarriage return
\vVertical tab
\fForm feed

Meta Characters (must be escaped)

Character Classes
\wWord (a-z, A-Z, 0-9, including _ (underscore))
\dDigit (0-9)
\SNot whitespace
\bMatch at beginning or end
\BDo not match at beginning or end
\0NUL character
\nNew line
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

^Start of line
$End of line

n(?=o)Lookahead, n followed by o
(not matching o)
n(?!o)Negative lookahead, n not followed by o
(not matching o)
(?<=o)nLookbehind, o preceding n
(?<!o)nNegative lookbehind, o not preceding n
.Any character except new line (\n)
(a|b)a or b
(?:...)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
\nnth group/subpattern