💻 Developer Tools

Regex Tester

Test a JavaScript regular expression and flags against sample text in real time.

Ready to use · Runs in your browser · No signup
Loading tool…

How to use the Regex Tester

Test JavaScript-compatible regular expressions against text and see match counts or syntax errors immediately in the browser.

Test a JavaScript regular expression against sample text and inspect matches without sending the pattern or sample to a server. Flags and syntax follow the current browser's JavaScript regex engine.

Input stays in the browser and is not sent to Fieldlet. Do not treat a formatting, encoding, test, or generated value as a substitute for security review.

  1. Enter the regular-expression pattern without slash delimiters.
  2. Enter JavaScript regex flags such as g, i, m, s, or u.
  3. Fieldlet compiles the expression and lists matching text when the expression is valid.

Last reviewed for accuracy:

Worked examples

Find four-digit years

Scenario: The pattern \b\d{4}\b with the global flag is tested against “Released 2024, reviewed 2026.”

Result: The matches are 2024 and 2026.

Word boundaries isolate the digit runs, \d{4} requires exactly four digits, and the global flag continues after the first match.

How the result is produced

The browser compiles the pattern and flags with JavaScript's RegExp engine. Invalid syntax is reported explicitly, and match iteration must guard against zero-length matches to avoid an endless loop.

  • The g flag finds multiple matches
  • The i flag makes letter matching case-insensitive
  • The m and s flags change anchor and dot behavior, not the input itself

Treat flags as part of the expression

The same pattern can produce different results when global, case-insensitive, multiline, dot-all, sticky, or Unicode behavior changes. Enter only valid JavaScript flag letters, without slash delimiters, and review the match count before reusing the expression elsewhere.

  • Use g when you need every match instead of the first.
  • Use i only when case should be ignored.
  • Test potentially expensive patterns on small representative input first.

Limitations and common mistakes

  • JavaScript regex features and Unicode behavior can differ from PCRE, .NET, Python, or database engines.
  • Catastrophic backtracking in a poorly designed pattern can freeze work on large input.

Common questions

Which regex flavor does this use?

It uses the JavaScript RegExp implementation provided by the visitor's browser.

Why does a pattern work elsewhere but fail here?

Regular-expression dialects differ. This tester follows the JavaScript syntax and features implemented by the current browser.