This form allows you to test regular expressions in Perl, PHP and JavaScript. The form returns the text with all hits highlighted. PHP always finds all matches while Perl or JavaScript consider the existence of the global modifier or its absence respectively. The Perl and PHP scripts are full Unicode capable.Take care: if you are on Windows and hit the line break server-side (Perl, PHP), then you will get two matches because \n on Windows is \r\n on Linux!

Language






Examples of successful matches and error messages as displayed by the form

/[A-Z]/

PHP:

All work and no play makes Jack a dull boy.

Perl:

All work and no play makes Jack a dull boy.

JavaScript:

All work and no play makes Jack a dull boy.

/[a-h]/g

PHP:

preg_replace(): Unknown modifier 'g'

Perl:

That’s one small step for man, onegiant leap for mankind.

JavaScript:

That’s one small step for man, onegiant leap for mankind.

/(?<=\s)[a-z]/

PHP:

To be, or not to be, that is the question:

Perl:

To be, or not to be, that is the question:

JavaScript:

SyntaxError: invalid regexp group

/[a-z]{6,7}(?=\s)/

PHP:

It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife.

Perl:

It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife.

JavaScript:

It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife.

/\w(\w*/

PHP:

preg_replace(): Compilation failed: missing ) at offset 6

Perl:

Unmatched ( in regex; marked by <-- HERE in m/(?)\w( <-- HERE \w*/ at /var/www/xxxxxxx/ingram-braun.net/httpdocs/perl/regex.pl line 39.

JavaScript:

Online Regex Tester (Perl, PHP, JavaScript) 1
SyntaxError: unterminated parenthetical