What a regex tester is for
A regular expression is a small pattern language for finding things in text — an email address, a date, a price, a stray double space. Writing one is quick; being sure it matches what you meant is not. This page runs your pattern against real text as you type and shows exactly what it caught.
The flags
g— find every match, not just the firsti— ignore upper and lower casem—^and$match the start and end of each lines—.also matches a newline
A quick reference
\ddigit ·\wletter, digit or underscore ·\swhitespace+one or more ·*none or more ·?optional ·{2,4}between two and four[abc]any of these ·[^abc]none of these ·|either side( )capture a group, used as$1,$2in the replacement^start ·$end ·\bword boundary
How to use the regex tester
- Type the pattern without the surrounding slashes — just
\d{4}, not/\d{4}/g. - Tick the flags you need, then paste your text. Matches are highlighted immediately.
- Add a replacement to see the rewritten text, using
$1and$2for the captured groups.
Things to watch
- This uses the JavaScript regex engine. PHP, Python and Java differ in places, particularly around lookbehind and named groups.
- A pattern with nested repeats, like
(a+)+b, can take a very long time on certain inputs. Keep patterns simple. - Your text stays in the browser — nothing is uploaded, so it is safe to paste real data.
Frequently asked questions
How do I test a regular expression?
Type the pattern without slashes, paste the text you want to search, and the matches are highlighted as you type. Capture groups are listed under each match.
What do $1 and $2 mean in the replacement?
They stand for the text captured by the first and second bracketed group in your pattern. Replacing (\w+)@(\w+) with "$1 at $2" turns rafi@softyfy into "rafi at softyfy".
Does this work for PHP or Python regex?
Mostly. The core syntax is shared, but each language has its own extensions. Anything using lookbehind, named groups or Unicode property escapes should be checked in the language you will run it in.