Skip to main content

Free Regex Tester

Test regular expressions against text in real time. See highlighted matches, groups, and match details.

Works offline once loaded
//g
Flags:

g Global - find all matches · i Case-insensitive · m Multiline - ^ and $ match line boundaries · s Dotall - dot matches newline · u Unicode - full code-point matching · y Sticky - each match must start where the last one ended

Examples:

Matches

The quick brown fox jumps over the lazy dog. Pack my box with five dozen liquor jugs.Enter a pattern above to see matches highlighted here.

Common uses

  • Test Regex for Form ValidationWrite and test regular expressions for validating emails, phone numbers, postcodes, and other form inputs.
  • Parse Server Logs with RegexWrite regex patterns to extract timestamps, IP addresses, error codes, and structured data from log files.
  • Extract and Replace Text with RegexUse regex to find patterns, extract data, or prepare find-and-replace operations before running them in your editor.
  • Test URL Routing PatternsWrite and test regex patterns for URL routing rules in Express, Nginx, and Apache.
  • Extract Data with RegexBuild and test patterns to extract structured data from unstructured text, HTML, or markdown.

How It Works

This tool runs entirely in your browser using JavaScript's built-in RegExp engine — the same engine powering every script on every website you visit. No pattern, test text, or match result is ever sent to a server.

  1. 1
    Pattern compiled to RegExp
    As you type, the tool calls new RegExp(pattern, flags) using the flags you've toggled (g, i, m, s, u, y). If the pattern is syntactically invalid, the caught error message is shown inline immediately — no submit button needed.
  2. 2
    exec() loop collects matches
    The engine runs re.exec(text) in a loop, recording each match's character index, length, full value, numbered capture groups, and any named groups. A safety cap of 10,000 matches prevents runaway patterns, and a zero-length match guard advances lastIndex to avoid infinite loops.
  3. 3
    Text split into highlighted spans
    A buildSegments function walks the match offsets and slices the source text into alternating unmatched and matched segments. Matched spans are wrapped in <mark> elements styled with cycling colors so overlapping or adjacent matches remain visually distinct.
  4. 4
    Replace mode via String.replace
    Switching to replace mode calls testText.replace(new RegExp(pattern, flags), replacement) directly, which means backreferences like $1 and $<name> work exactly as they would in JavaScript code. The result text is shown live and can be copied to the clipboard.

Related Tools

Frequently Asked Questions