Toolbox for developers / Online Regular expression tester

Regex Tester

This online tool allows you to test regular expression in JavaScript.

You can consult the regex documentation or see the full user guide to help you to use this regular expression tester. It is a beta version.

Regular expression to test
Flags
String to test

Explanation

User guide

  • Copy and paste or directly type your regular expression to test in the "Regular expression to test" field.
  • Select the flags you want in "Flags" section.
  • Copy and paste or directly type your test string in the "test string" field.
  • As soon as you make a modification (regular expression, flags or test string):
    • A message indicates the number of correspondence
    • An explanation is generated about of your regex. It uses regulex, it is a JavaScript Regular Expression Parser & Visualizer (Written in pure JavaScript).
    • Your regex is highlighted according to the syntax. It is a beta version, it can be wrong.
  • You can save your regex in order to share it. See "Save and Share" section.

Substitutions are not managed.


The unavoidables

Some regex that can be useful (without warranty).

Email address

The last RFC is complex, there is no reliable solution, this regex should work more than 99% of the time (You must turn off case sensitivity).

^((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))$

Alphanumeric

The regex below allows to validate alphanumeric string. Be careful, \w authorizes the underscore character.

^[a-zA-Z0-9]+$

MD5

The regex below allows to validate MD5 string.

^[a-f0-9]{32}$

IP V4

The regex below allows to validate IP v4.

^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$


About regular expression

A regular expression is a sequence of characters that define a search pattern. This pattern is used by string searching algorithms for find or replace text.

It can be useful to validate an EMAIL address or an IP address.



Save and Share
Save this regular expression in order to share it.
Documentation
. Matches any single character except line break (\n, \r)
x? Matches with the preceding item 0 or 1 time. For example, /hello?/ matches with "hell" and "hello".
x+ Matches with the preceding item 1 or more times. For example, /hello+/ matches with "hello", "helloooooo"....
x* Matches with the preceding item 0 or more times. For example, /hello*/ matches with "hell", "helloooooo"....
$ Matches the end of the input.
^ Matches the beginning of the input.
[xyz] A character set: Matches any one of the enclosed characters in the brackets.
[x-z] A range of characters: For example, [x-z] is the same as [xyz]
[^xyz] A negated character set: Matches anything that is not enclosed in the brackets.
x|y Matches either x or y.
\t Matches a tab character
\r Matches a carriage return
\n Matches a linefeed
\d Matches any digit. It is the same as [0-9]
\D Matches any character that is not a digit. It is the same as [^0-9]
\w Matches any alphanumeric character (Latin alphabet and underscore). It is the same as [A-Za-z0-9_]
\W Matches any character that is not a alphanumeric character (Neither Latin alphabet nor underscore). It is the same as [^A-Za-z0-9_]
\s Matches a single white space character (space, tab, line break). It is the same as [ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]
\S Matches a single character other than white space (space, tab, line break). It is the same as [^ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]


You can report a bug or give feedback by adding a comment (above) or by clicking "Contact us" link (at the top right hand corner of the page).

Comments





The tools are provided "as is", without warranty of any kind, either express or implied.