Back to Home

JavaScript Regex Tester

Test JavaScript regular expressions against sample text. Highlight matches, inspect capture groups, and preview replacements as you type.

Processed locally — your data never leaves your browser
Loading tool...

What is JavaScript Regex Tester?

Test patterns using your browser’s JavaScript RegExp engine. Match highlights, capture groups, and replacement previews update as you edit. Use the flags to change how the pattern matches.

How to use

  1. 1

    Enter a pattern and a test string, or start with Load Email Example.

  2. 2

    Toggle flags such as g for all matches or i to ignore case. Review the highlighted matches and capture groups.

  3. 3

    Enter a replacement to preview the result. Use $1 for the first capture group or $& for the whole match.

Common Use Cases

  • 1

    Build and test email, phone, or URL validation patterns before adding them to form validation logic

  • 2

    Construct capture groups to extract structured fields from server log lines

  • 3

    Check how flags change matches across lines or letter cases in JavaScript

  • 4

    Test edge cases against real sample data to verify your pattern handles them correctly

  • 5

    Quickly prototype replacement patterns for string transformation without spinning up a REPL

Try an Example

Email match pattern

Example Input

Pattern: ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$
Text: help@bitesizetools.com

Frequently Asked Questions

Which regex engine does this tool use?

It uses your browser’s JavaScript RegExp engine. Test Python, Go, or PCRE patterns in their own engines because syntax and behavior can differ.

Why does the tester show only one match?

Enable the g flag to find all matches. Without it, the tester reports the first match.

Related Tools