Skip to content

RegEx Tester

Test a JavaScript regular expression against sample text and see the matches and capture groups.

RegEx Tester

Test and validate your regular expressions.

//
Test String
Match Preview0 matches
Matches

No matches yet.

What RegEx Tester does

A regular expression that looks right frequently is not, and the fastest way to find out is to run it against real text rather than to reason about it.

This tool uses your browser's own regular expression engine, so the behaviour you see here is exactly the behaviour you will get in JavaScript running in a browser or in Node.

  • Highlight every match in the sample text
  • List matches with their position and capture groups
  • Accept any flag combination the JavaScript engine supports
  • Preview a replacement string

How to use RegEx Tester

  1. 1

    Enter the pattern

    Type the expression without the surrounding slashes, exactly as you would pass it to the RegExp constructor.

  2. 2

    Set the flags

    g matches all occurrences rather than stopping at the first, i ignores case, m makes ^ and $ match at line breaks, and s lets a dot match a newline.

  3. 3

    Paste sample text

    Use text that contains both the cases you want to match and the cases you want to exclude.

  4. 4

    Check the matches and groups

    The match list shows what was captured in each group, which is where most incorrect patterns reveal themselves.

Example

Capturing the parts of a date

Input

Pattern: (\d{4})-(\d{2})-(\d{2})
Text: Released 2026-09-08 and patched 2026-09-21

Output

Match 1: 2026-09-08 → groups: 2026, 09, 08
Match 2: 2026-09-21 → groups: 2026, 09, 21

Limits and known behaviour

  • This is the JavaScript dialect. Patterns written for PCRE, Python, Ruby, Java or Go may behave differently or fail to compile, particularly recursion, possessive quantifiers and atomic groups.
  • There is no execution timeout. A pattern with nested quantifiers over a long string can cause catastrophic backtracking and freeze the tab until you close it.
  • The tool does not explain a pattern in words or draw a railroad diagram; it shows what the pattern matches.
  • Lookbehind is supported only if your browser supports it, since the engine is the browser's own.

Privacy and data handling

Runs entirely in your browser

  • Your input is processed by JavaScript running in this page. The tool sends no request anywhere, so nothing you paste is transmitted or logged by this site.
  • Nothing is saved between visits. Closing or reloading the tab discards whatever is in the fields.

Site-wide data handling, including analytics and advertising, is described in the privacy policy.

Frequently asked questions

Why does my pattern only find the first match?

The global flag is missing. Without g, the engine stops at the first match. Add g to the flags field.

Why did the page freeze?

Almost certainly catastrophic backtracking: a pattern such as (a+)+$ against a long non-matching string forces the engine to try an exponential number of paths. Rewrite the pattern to avoid nested quantifiers over overlapping character sets.

Does a pattern that works here work in my language?

It works in JavaScript. Other languages share most syntax but differ in the details, so verify anything using advanced constructs in the target language.