Regex Tester
Test a pattern against text with live matches.
About Regex Tester
A regex tester runs a JavaScript regular expression against sample text, highlighting matches as you type, with capture groups, positions and a replace preview.
How to use
- Type the pattern without surrounding slashes, for example
\d+rather than/\d+/. - Tick the flags you need. Only g (global) is on by default; without it, only the first match is shown.
- Paste the test text. Matches are highlighted in place and counted as you type.
- Copy to get all matched strings, one per line. Below the highlighted text, "Groups and positions" lists every match with its numbered and named groups and character offsets, and "Replaced" shows the test text after
String.replacewith the "Replace with" field. A syntax error in the pattern is shown under it.
What it supports
| Flag | Meaning |
|---|---|
| g | Find every match, not just the first |
| i | Ignore case |
| m | ^ and $ match at line starts and ends, not only the string ends |
| s | . also matches newlines |
| u | Unicode mode: \p{L} property escapes and correct handling of characters above U+FFFF |
| v | Unicode sets mode: set operations inside classes and string properties; cannot be combined with u |
| y | Sticky: the match must start exactly at lastIndex |
| d | Indices: records the start and end of every group |
- Uses the browser's
RegExp, so the syntax is JavaScript (ECMAScript): lookbehind, named groups(?<name>…)and\p{…}with the u flag all work; possessive quantifiers, atomic groups and\A/\zdo not. - Empty matches are dropped, so a pattern such as
a*reports only the non-empty hits. - At most 5,000 matches are highlighted and listed; the count still covers all of them.
- Matching runs in a Web Worker and is stopped after 2 seconds, so a catastrophically backtracking pattern reports a timeout instead of freezing the tab.
Example
Pattern \b\d{4}-\d{2}-\d{2}\b Flags g
Text Released 2024-03-15, patched 2024-04-02.
→ 2 matches: 2024-03-15, 2024-04-02
Privacy
Matching runs in the browser. No request is made, and nothing is stored.
Frequently asked questions
- What does the g flag do in regex?
- Global: the expression finds every match in the text instead of stopping at the first. In JavaScript it also makes matchAll and replaceAll work across the whole string.
- What is the difference between greedy and lazy quantifiers?
- A greedy quantifier such as .* matches as much as it can and gives back only if the rest of the pattern fails; a lazy one such as .*? matches as little as possible. On <b>x</b><b>y</b>, <b>.*</b> matches the whole string while <b>.*?</b> matches only <b>x</b>.
- Why does my regex work in Python but not here?
- This tester uses JavaScript syntax. Python-only features include (?P<name>…) for named groups (JavaScript uses (?<name>…)), inline flags like (?i), and \A and \Z anchors. Lookbehind works in both.
- How do I match a literal dot or bracket?
- Escape it with a backslash: \. matches a dot, \[ an opening bracket, \\ a backslash. Inside a character class a dot is already literal, so [.] also works.