What a regex tester does and how this one works
A regular expression is a compact pattern language for describing the shape of text:
an email address, a hex colour, a date, a price. Instead of reading a string character by
character, you hand the engine a pattern and it reports where — and whether — that shape
appears. The hard part is that a tiny pattern can behave in surprising ways, so the fastest way
to get one right is to watch it run against real input. That is exactly what this tool does: as
you type, it compiles your pattern with the browser's native RegExp engine,
highlights every match in the test text, and lists each match with its position and capture
groups.
A worked example
Take the default pattern [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
with the flags gm. Paste a paragraph containing
[email protected] and [email protected] and both light up. The
g flag tells the engine to keep scanning after the first hit, so you see every
address rather than just one. Wrap the local part in parentheses —
([a-zA-Z0-9._%+-]+)@ — and that captured slice (for example support)
appears as Group 1 in the results table, alongside the full match and its
[start, end] index range.
The flags you can add
| Flag | Name | Effect |
|---|---|---|
g | Global | Find every match, not just the first. |
i | Ignore case | Treat A and a as equal. |
m | Multiline | Make ^ and $ match the start and end of each line. |
s | DotAll | Let . match newline characters too. |
u | Unicode | Enable correct handling of code points and \p{…} escapes. |
y | Sticky | Match only at the exact current position in the text. |
Greedy, lazy and catastrophic backtracking
Quantifiers like * and + are greedy by default — they
grab as much text as possible and then give it back only if the rest of the pattern fails. Add a
? (as in .*?) to make them lazy, stopping at the
first point that lets the match succeed. Beware nesting quantifiers such as
(a+)+ against non-matching input: the engine can try an exponential number of
paths before giving up, a performance trap known as catastrophic backtracking. Anchor
your patterns with ^ and $ and prefer specific character classes over
broad wildcards to keep matching fast.