Regex Tester
About this tool
About Regex Tester
Write a regular expression and see what it matches while you type. Every match is highlighted in the test string in alternating colours, with each capture group underlined in its own colour, and the match table lists the position, the full match and every numbered and named group, ready to download as CSV. Toggle the flags g, i, m, s, u, v, y and d with one click, or paste a whole literal like /^\d+$/gm and the pattern and flags are split for you. Switch to Replace to preview a substitution using $1, $<name>, $& and $$ before you put it in code. When a pattern is invalid you get a plain explanation of what is wrong, such as an unclosed group or a quantifier with nothing to repeat, next to the engine's own message. Matching runs in a background worker with a time limit, so a catastrophically backtracking pattern is stopped and explained instead of freezing the page. The tester uses your browser's JavaScript engine, so results match what JavaScript in this browser does, and nothing is uploaded. An optional AI button, on your own key, writes or explains a pattern.
Built and maintained by Abhi JainUpdated
How to Test a Regular Expression
- 1
Enter the pattern
Type the pattern into the Regular expression box, or paste a full /pattern/flags literal. Click Sample to load an example.
- 2
Set the flags
Click the flag buttons (global, ignore case, multiline, dotAll, unicode and others) to turn them on or off.
- 3
Add test text
Paste text into Test string. Matches are highlighted and listed in the Matches table with their capture groups.
- 4
Preview a replacement
Switch Mode to Replace, type the replacement using $1 or $<name>, and copy the result or download the matches as CSV.
Regex Tester: questions and answers
Which regex flavour does this tester use?
JavaScript (ECMAScript), using the regex engine built into your browser. Patterns behave as they will in browser code and in current Node.js versions; very new syntax such as the v flag may be missing from older engines. Most syntax is shared with PCRE, Python and Java, but some features differ: JavaScript has no possessive quantifiers, atomic groups or inline flags such as (?i).
Why does my regex only find the first match?
Without the g (global) flag, JavaScript stops after the first match. Turn on g to find every match. The status line under the panels tells you when only the first match is shown.
How do named capture groups work in JavaScript?
Write (?<name>…) to name a group, for example (?<year>\d{4}). In a replacement, use $<year> to insert it, and refer back to it inside the pattern with \k<year>. The match table shows each group under its name.
What is catastrophic backtracking?
Patterns with nested quantifiers like (a+)+ or (.*)*$ can try an exponential number of ways to match before failing. On a long string that can take minutes. This tester runs matching in a worker and stops it after two seconds, then explains the likely cause so you can rewrite it, for example (a+)+ as a+.
What do the m and s flags change?
With m (multiline), ^ and $ match at the start and end of every line instead of the whole text. With s (dotAll), the dot also matches line breaks. They are independent, so you can use both.
Can AI write or explain a regex for me?
Yes, optionally. Click AI and describe what to match, for example Indian mobile numbers, and the suggested pattern is checked to compile before you apply it; or ask for a step-by-step explanation of the pattern in the box. It uses your own AI key and sends only your description, the pattern and up to 4,000 characters of the test text, directly to your provider. Without AI, nothing leaves your browser tab.
Ready-made Regex Tester presets
Related Tools
- Regex LibraryReady-made, tested regex patterns for emails, URLs, IPs, dates, phone numbers, Indian PAN, GSTIN, PIN and more, with code for five languages.
- Regex Match ExtractorExtract every regex match or capture group from text into a clean list, JSON array or CSV, with presets, de-duplication and sorting.
- Regex EscapeEscape special characters so literal text is safe inside a regular expression, for JavaScript, Python, POSIX or a character class.
- Diff CheckerCompare two texts by line, word or character, side by side or unified, with ignore options, stats and a downloadable patch.
- JSON FormatterBeautify, minify and validate JSON with exact error locations, without changing a single value.