Help

Javascript Regular Expression Validator

This tool is a web-based regular expression validator for Javascript that lets you easily test and write regular expressions for Javascript. It can be very useful to use while you are writing Regular Expressions for Javascript, and most other languages as they are pretty similar in their implementation. The tool helps you check syntax and also provides a regular expressions library for your use as well.

Show/Hide Library

Regular Expression Library

Label REGULAR EXPRESSION Example
Date Format (m/d/y)^([\d]|1[0,1,2])/([0-9]|[0,1,2][0-9]|3[0,1])/\d{4}$12/21/2005TEST
Decimal Number^\d*[0-9](\.\d*[0-9])?$234.342TEST
Document Filenames^[a-zA-Z0-9-_\.]+\.(pdf|txt|doc|csv)$world-domination.pdfTEST
E-mail Address^([0-9a-zA-Z]+([_.-]?[0-9a-zA-Z]+)*@[0-9a-zA-Z]+[0-9,a-z,A-Z,.,-]*(.){1}[a-zA-Z]{2,4})+$info@netshiftmedia.comTEST
HTML Color Codes^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$#00ccffTEST
Image Filenames^[a-zA-Z0-9-_\.]+\.(jpg|gif|png)$new-pic_company.jpgTEST
IP Address^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$192.168.0.1TEST
Multimedia Filenames^[a-zA-Z0-9-_\.]+\.(swf|mov|wma|mpg|mp3|wav)$company-presentation.swfTEST
MySQL Date Format^\d{4}-(0[0-9]|1[0,1,2])-([0,1,2][0-9]|3[0,1])$2005-09-02TEST
Phone Number^[2-9]\d{2}-\d{3}-\d{4}$250-555-4542TEST
Postal Code (CAD)^([A-Z][0-9]){3}$V2B2S3TEST
Time Format (HH:MM)^([0-1][0-9]|[2][0-3])(:([0-5][0-9])){1,2}$12:29TEST
URL^(http[s]?://|ftp://)?(www\.)?[a-zA-Z0-9-\.]+\.(com|org|net|mil|edu|ca|co.uk|com.au|gov)$http://www.netshiftmedia.comTEST
Versatile Phone Number^(([0-9]{1})*[- .(]*([0-9a-zA-Z]{3})*[- .)]*[0-9a-zA-Z]{3}[- .]*[0-9a-zA-Z]{4})+$1.245.532.3422TEST

Show/Hide Resources

Regular Expression Resources

x

Regular Expression Reference

AssertionDescription
^Matches at the beginning of the string.
$Matches at the end of the string.
\bMatches a word boundary (between \w and \W), when not inside [].
\BMatches a non-word boundary.
Quantifier Range
{m,n} Must occur at least m times, but not more than n times.
{n,} Must occur at least n times.
{n} Must occur exactly n times.
* Must occur 0 or more times (same as {0,}).
+ Must occur 1 or more times (same as {1,}).
? Must occur 0 or 1 time (same as {0,1}).
CharacterMatches
\n Linefeed
\r Carriage return
\t Tab
\v Vertical tab
\f Form-feed
\d A digit (same as [0-9])
\D A non-digit (same as [^0-9])
\w A word (alphanumeric) character (same as [a-zA-Z_0-9])
\W A non-word character (same as [^a-zA-Z_0-9])
\s A whitespace character (same as [ \t\v\n\r\f])
\S A non-whitespace character (same as [^ \t\v\n\r\f])