Regex Tester & Debugger

Write a regular expression and see every match highlighted in your test text as you type, with capture groups broken out.

/ /

Matches highlighted

Match details

#MatchIndexGroups
Quick reference
. any character
\d digit
\w word character
\s whitespace
\b word boundary
^ start of string
$ end of string
* zero or more
+ one or more
? optional
{2,5} between 2 and 5
[abc] any of a, b, c
[^abc] none of a, b, c
(x) capture group
(?:x) non-capturing
(?<n>x) named group
x|y x or y
(?=x) lookahead

About the regex tester

Regular expressions are far easier to debug when you can see what they match. Type a pattern and matches highlight live in the sample text, with a detail panel listing each match, its position and the contents of every capture group, including named groups. All JavaScript flags are supported: global, case-insensitive, multiline, dotAll, unicode and sticky. A quick reference for the common tokens sits alongside so you do not need to keep another tab open.

How to use the regex tester

  1. Enter your regular expression pattern, without the surrounding slashes.
  2. Toggle the flags you need, such as g for global and i for case-insensitive.
  3. Paste sample text into the test area to see matches highlighted live.
  4. Check the match details panel for positions and capture group contents.

Frequently asked questions

Which regex flavor does this use?
JavaScript (ECMAScript). It is close to PCRE for everyday patterns but differs in places: JavaScript has no lookbehind in older engines, no possessive quantifiers, and no recursion. Patterns written for Python or PHP may need small adjustments.
What does the global flag change?
Without `g`, the regex stops at the first match. With `g`, it finds every match in the string. Note that a global regex object keeps a `lastIndex` position between calls, which is a classic source of bugs when reusing the same object.
How do I match a literal dot or question mark?
Escape it with a backslash: `\.` matches a literal period and `\?` matches a literal question mark. Unescaped, `.` matches any character and `?` makes the preceding token optional.
Why is my regex extremely slow?
Probably catastrophic backtracking, caused by nested quantifiers such as `(a+)+`. On a non-matching input the engine explores exponentially many paths. Rewrite the pattern to avoid nesting quantifiers, or anchor it more tightly.