Search tools

Regex Tester

Test a JavaScript regular expression, see its matches and groups, replace and extract.

Regex

Test

JavaScript regex, safely

  • As browsers run it: Patterns and flags follow JavaScript (g, i, m, s, u, y). PCRE, Python and .NET differ in places, so test in the flavour you will use.
  • Matches and groups: Every match with its position and its numbered and named groups; Replace previews the result, Extract lists matches or one group.
  • Runaway patterns stop: The pattern runs in a separate worker that is stopped after a short time, so catastrophic backtracking cannot freeze the page.

Frequently asked questions

Why does my pattern only find one match?

Without the g flag, JavaScript stops after the first match. Turn on g to find all.

Can the replacement run code?

No. Only replacement text with $&, $1, $<name>, $` and $' is supported; no functions are run.