<

Online JavaScript Regex Tester

Test regular expressions and highlight matches as you type.

Ready
Regex Pattern and flags
Text Input
Result Highlighted matches

How to use the Regex tester

Enter a pattern, flags and test text. The tester uses your browser’s JavaScript RegExp engine to highlight matching text and count matches.

  1. Enter the pattern without the surrounding slashes. Use \d{2} instead of /\d{2}/.
  2. Enter flags in the next field. Use g for all matches or gi for case-insensitive matching across the text.
  3. Paste the text you want to test and check the highlighted matches and count.
  4. If the pattern or flags are invalid, read the browser error and correct the input.

Examples

Finding formatted Brazilian taxpayer IDs (CPFs)

Pattern (flags: g)
\b\d{3}\.\d{3}\.\d{3}-\d{2}\b
Test text
Sample IDs: 123.456.789-00 and 987.654.321-00.

The pattern finds text in the format 000.000.000-00. It does not check the verification digits.

Extracting parts of a date with named groups

Pattern
(?<day>\d{2})/(?<month>\d{2})/(?<year>\d{4})
JavaScript example
const match = '18/07/2025'.match(/(?<day>\d{2})\/(?<month>\d{2})\/(?<year>\d{4})/);
match.groups.year; // "2025"

The tester highlights the whole match. To read individual capture groups, use the pattern in your JavaScript code.

Common errors and fixes

ProblemCauseHow to fix it
Slashes around the pattern The pattern field contains /\d+/g. Enter \d+ as the pattern and g in the flags field.
Unescaped special characters Dots, parentheses, brackets and + have special meanings. Use a backslash before a literal character, as in \. \( \[ \+.
Only the first match appears The g flag is missing. Add g to the flags field.
The pattern matches too much text A quantifier such as .* is greedy. Use a lazy quantifier such as .*? or a more specific character class such as [^"]*.
Anchors do not match individual lines ^ and $ are input boundaries by default. Add m to use line boundaries.

What this tool does and does not do

Privacy and storage

Your input is processed in your browser and is not sent to Novemax. Your pattern, flags and test text are saved in your browser local storage so you can resume later. On a shared computer, clear the editor before leaving. The site uses Google Analytics and Google AdSense according to your cookie preferences; these services do not receive the text you type in the editor.

Frequently asked questions

Which regex engine does the tester use?

It uses the JavaScript engine in your browser. Patterns written for another language may behave differently.

Is my test text sent to a server?

The test runs in your browser. Your pattern, flags and test text are saved in browser local storage.

Which flags can I use?

Use the flags supported by your browser, such as g (global), i (case-insensitive), m (multiline), s (dot matches line breaks), u (Unicode) and y (sticky). Invalid or repeated flags cause an error.

Can I validate an email address or CPF with a regex?

A regex can check the format. Confirm email ownership with a verification step and check CPF verification digits separately.

Keep learning

Updated on November 5, 2026 · Tool maintained by Novemax. Found an issue or have a suggestion? Contact us.