Regex tester

Test patterns against real text, right in your browser.

Matches

  
#TypeValuePosition

Runs in your browser. Nothing you type is sent anywhere.

How to test a regular expression

  1. Type or paste your pattern and pick the flags you need.
  2. Paste the text you want to match against.
  3. Check the highlighted matches, the groups table, or preview a replacement.

Regex syntax quick reference

PatternMatches
\dAny digit, 0 to 9
\wAny letter, digit or _ character
\sAny whitespace character
+One or more of the previous token
*Zero or more of the previous token
?Zero or one, or makes a quantifier lazy
^ and $Start and end of the string or line

JavaScript regex features

FeatureSyntaxNote
Named groups(?<name>...)Supported since ES2018
Lookbehind(?<=...) and (?<!...)Supported since ES2018
Unicode modeu flagNeeded for Unicode property escapes like \p{Letter}
Case-insensitivei flagSame idea as most other languages

Tips for writing patterns

  • Escape special characters like . ( ) [ ] with a backslash when you mean the literal character.
  • Use a non-capturing group (?:...) for grouping when you do not need to reference that match later.
  • Greedy quantifiers grab as much as possible. Add a ? after one, like +?, for lazy matching that stops at the first possible point.
  • Test against edge cases, such as an empty string or extra whitespace, not only the text you expect to match.

Regex tester FAQ

Why did my pattern stop responding?

Some patterns can backtrack exponentially on certain text. Matching runs in a background worker with a 1.5 second limit, so a runaway pattern is stopped instead of freezing the tab.

What do the flags mean?

g finds every match instead of just the first, i ignores case, m makes ^ and $ match line by line, s lets a dot match newlines, u turns on full Unicode mode, y anchors matching to the last index, and d adds start and end positions for each match.

Does the replacement box change my test text?

No. It shows what String.replace would produce in a separate result box, so the test string you typed stays exactly as it was.

Are named capture groups supported?

Yes. Write a group as (?<name>...) and its name appears next to the group number in the matches table.

Is my text sent anywhere?

No. Matching runs in a worker inside your own browser tab, and nothing you type leaves the page.

Which regex flavor does this use?

Your browser's native JavaScript RegExp engine, the same one that runs your patterns if you're building a web app or a Node.js script.

What is catastrophic backtracking?

It's when a pattern with nested repeated groups, like (a+)+b, can take exponentially longer to fail as the input grows by even one character. The 1.5 second worker timeout here catches a pattern like that before it can freeze the page.

Can ^ and $ match the start and end of each line, not just the whole string?

Yes, turn on the m (multiline) flag. Without it, ^ and $ only match the very start and end of the whole test string.

Related tools