Skip to content
Toolore

Developer Tools

Regex Tester

Type a pattern and some text and every match is highlighted as you type, with its position and capture groups listed below. Matching runs in a background worker, so a pattern that backtracks out of control is stopped after a second and a half instead of freezing the tab.

Flags

Enter a pattern and some text to test it against.

How to use this tool

  1. Type your pattern without the surrounding slashes, or start from one of the common patterns.
  2. Tick the flags you need. g finds every match; without it only the first is reported.
  3. Paste the text to test against. Matches are highlighted and listed with their position and groups.
  4. To check a replacement, tick “Also preview a replacement” and enter it, using $1 for the first group or $<name> for a named one.
  5. Copy the finished pattern as a /literal/ or as a new RegExp() call for your code.

Worked examples

Pulling the unit out of “10-kg and 5-lb”

  1. Pattern: (\d+)-(?<unit>[a-z]+) with the g flag

Two matches: “10-kg” with groups 10 and kg, and “5-lb” with groups 5 and lb. The named group is available as $<unit> in a replacement.

Swapping “name@domain” pairs

  1. Pattern: (\w+)@(\w+)
  2. Replacement: $2:$1

“ana@x bo@y” becomes “x:ana y:bo”.

Notes and limitations

  • Patterns run in your browser's own JavaScript engine, so the result is exactly what the same regex does in JavaScript or TypeScript code.
  • Other languages differ in places. Python, PHP (PCRE), Java and .NET support features JavaScript lacks, such as possessive quantifiers or inline flags like (?i), and the reverse is also true. Test there before relying on an edge case.
  • A pattern that runs for more than 1.5 seconds is stopped. That almost always means catastrophic backtracking from nested quantifiers such as (a+)+ — worth fixing, because the same pattern can stall a server.
  • The match table lists the first 200 matches, and counting stops at 1,000.
  • The common patterns are practical starting points, not full validators. The email pattern, for example, accepts everyday addresses but not every address the standard allows.
  • Everything runs in your browser and nothing is uploaded. That said, treat any third-party website with caution when handling production data — if a value would cause real damage if leaked, process it with your own local tooling instead.

Frequently asked questions

Why does my pattern find only one match?

The g (global) flag is off. Without it, a JavaScript regex stops at the first match, both here and in your code.

Do I need to escape slashes?

Not in the pattern box, because it is passed to new RegExp() directly. In a /literal/ in code, a forward slash must be written as \/ — the copy-as-literal button gives the pattern exactly as typed, so add those escapes if it contains slashes.

What do ^ and $ match?

The start and end of the whole text — unless the m (multiline) flag is on, when they also match at the start and end of each line.

How do I match an Indian mobile number?

Use the “Indian mobile” preset: an optional +91, then a ten-digit number starting with 6, 7, 8 or 9. It checks the shape of the number, not whether it is in service.