Skip to content
SDETRole
SDETRole

JSON & Data

Regex Tester

Test JS regex with live highlighting, groups and replace preview.

Runs entirely in your browser No sign-up

Flags
QA patterns:

Test string

0 chars

Highlighted · 0 matches

Matches are highlighted here.

Replace preview

Enable to preview String.replace with your pattern, for example to mask emails or tokens in logs.

About this tool

Regular expressions show up in test code all the time: asserting a log line, extracting an ID from a response, validating a format, masking secrets in reports. This tester uses the browser’s own JavaScript RegExp engine, so results match what Playwright, Cypress, Jest and Node will do. Matches are highlighted as you type, every capture group (numbered and named) is listed with its position, and the replace preview shows the result of String.replace. Matching runs in a background worker that is stopped after 1.5 seconds, so a catastrophic backtracking pattern cannot freeze the page.

How to use it

  1. Enter a pattern without the surrounding slashes and toggle the flags you need (g, i, m, s, u, y).
  2. Paste a test string, or click one of the QA patterns to load a pattern with matching sample text.
  3. Check the highlighted text and the match table for groups and indices.
  4. Enable “Replace preview” to try a replacement using $1, $<name> or $&.

Regex Tester FAQ

Will a pattern that works here work in Java or Python?

Mostly, but not always. The basics are shared, but named groups are written (?<name>) in JavaScript and Java and (?P<name>) in Python, lookbehind support differs, and the s and y flags are JavaScript-specific. Test in the target language for anything advanced.

Why did the tester stop with a timeout?

Patterns with nested quantifiers, such as (a+)+ or (.*)*, can take exponential time on inputs that almost match. That is called catastrophic backtracking, and the same pattern could hang a test run or a server (ReDoS). Make the inner quantifier more specific or remove the nesting.

Why do I see only one match?

Without the g (global) flag a JavaScript regex stops after the first match. Turn g on to find every occurrence; that is also what String.prototype.matchAll and replaceAll require.

Type to search across SDETRole.

Full-text search by Pagefind · runs in your browser Open search page →