What this regex tester does
Regular expressions describe text patterns compactly, but they are notoriously hard to read and easy to get subtly wrong. This tester runs your pattern with the JavaScript regex engine, highlights every match in the test string as you type, lists capture groups and named groups for each match, and lets you toggle the g, i, m, s, u and y flags with one click.
How to use it
- Enter the pattern between the slashes, without delimiters, for example
(\w+)@(\w+)\.com. - Toggle flags: g finds all matches, i ignores case, m makes
^and$match at line breaks, s lets.match newlines, u enables full Unicode, y anchors at the last position. - Paste sample text into Test string.
- Matches are highlighted in the middle panel; groups are listed below with their positions.
Practical examples
- Extract order numbers:
ORD-(\d{6})with thegflag captures every six-digit number followingORD-. - Validate a slug:
^[a-z0-9]+(?:-[a-z0-9]+)*$acceptsmy-first-postbut rejects double hyphens and uppercase. - Named groups for dates:
(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})makes code likematch.groups.yearself-documenting. - Log filtering:
^ERROR.*timeoutwith themflag finds lines that start with ERROR and mention a timeout.
Tips and edge cases
- Escape special characters
. * + ? ^ $ { } ( ) | [ ] \ /when you mean them literally. - Quantifiers are greedy by default.
<.+>matches from the first<to the last>; use<.+?>for the shortest match. - Nested quantifiers such as
(a+)+can cause catastrophic backtracking on long inputs. Prefer specific character classes. - Without the
uflag, emoji count as two characters and\wnever matches accented letters. - The tester stops after 1,000 matches to keep the page responsive.