Regex Tester

Enter your regular expression in the text box below, then enter text you'd like to test the regular expression on in the second text box. The results will be highlighted below.


Test String


Regex Help

Regex, also known as regular expressions, is a way of defining a text search pattern. It is usually used for finding or replacing text in a string.

The following tables show you the most commonly used characters and their uses.

Character Class ASCII Description
\w [A-Za-z0-9_] Alphanumeric characters and "_"
\a [A-Za-z] Alphabetic characters (upper and lowercase)
\s [ \t] Space and tab
\d [0-9] Numerical Digits
\D [^0-9] Non-numerical digits
\l [a-z] Lowercase letters
\p [\x20-\x7E] Any visible character or the space character
\s [ \t\r\n\v\f] Any whitespace characters
\S [^ \t\r\n\v\f] Any non-whitespace characters
\u [A-Z] Uppercase letters
Metacharacter Description

Credit to Wikipedia for some of the regex descriptions.


Using regex in JS is really easy since it is built right in to the language. Here is a quick example:

"12 34".match( /\d+/g )    // ['12', '34']

Regex strings in JavaScript are a bit different than normal strings. They're delimited with the forward slash (/) character instead of quotes.

At the end of the regex string I showed above you might have noticed the extra g (global). This is a flag indicating that we want to find all matches in the string, and not just the first one. There are a few other flags available, like ignore case (i), multi-line (m), and sticky (y), which is still in experimental mode.