regular expression tester
hints
| ^ |
Beginning of string |
| $ |
End of string |
| . |
Any single character |
| n |
Exactly one "n" |
| [abc] |
A single character: a, b, or c |
| [a-d] |
Any lowercase character between a and z |
| [K-O] |
Any uppercase character between K and O |
| [a-zA-Z] |
Any alphabetical character (both lowercase or uppercase) |
| [0-9] |
Any number |
| [^a-d] |
Negation: matches any single character but lowercase characters between a and d |
| () |
Subexpression: parentheses group strings together |
| | |
Alternation: matches either the subexpression to the left or to the right |
| (a|b) |
Either a or b |
| \ |
Escapes a special character for literal interpretation |
repetition operators
| {3} |
Match exactly 3 occurences of the previous expression |
| {3,} |
Match at least 3 or more occurences of the previous expression |
| {3,5} |
Match at least 3 but no more than 5 occurences of the previous expression |
| * |
Match 0 or more occurences of the previous expression - the same as {0,} |
| ? |
Match 0 or 1 occurences of the previous expression - the same as {0,1} |
| + |
Match 1 or more occurences of the previous expression - the same as {1,} |
character classes
| [[:alnum:]] |
Any alphanumeric character - not the same as [a-zA-Z0-9]. This includes also locale set characters (e.g. á, ñ) |
| [[:alpha:]] |
Any alphabetical character - includes locale set characters |
| [[:blank:]] |
Space or tab |
| [[:cntrl:]] |
Any control character (^x, ^c, ^h etc.) |
| [[:digit:]] |
Any digit - the same as [0-9] |
| [[:graph:]] |
Any non-blank character (not spaces, control characters etc.) |
| [[:lower:]] |
Any lowercase English character - the same as [a-z] |
| [[:print:]] |
Like [[:graph:]] but includes space character |
| [[:punct:]] |
Punction and other characters (@, parentheses, ...) |
| [[:space:]] |
Any whitespace character (space, tab, carriage return, new line, new page) |
| [[:upper:]] |
Any lowercase English character - the same as [A-Z] |
| [[:xdigit]] |
Any hexadecimal numeric - the same as [0-9a-fA-F] |
| [[:<:]] |
Beginning of word |
| [[:>:]] |
End of word |
metacharacters
Metacharacters need to be escaped (i.e. preceded by \) if you want to free them from their special meaning. No escaping is neccessary inside square brackets – everything between [] is interpreted literally.
further reading
perl.com
Back to top