Regex Tester

Test a regular expression against sample text with live match highlighting.

//g

5 matches

Order #12345 shipped on 2024-01-15, tracking number 987654321.

Match details

Match 1: "12345" at index 7
Match 2: "2024" at index 24
Match 3: "01" at index 29
Match 4: "15" at index 32
Match 5: "987654321" at index 52

What Is the Regex Tester?

This tool tests a JavaScript regular expression against a block of text, highlighting every match live as you type, entirely in your browser.

How Is the Regex Tester Calculated?

Your pattern and flags are compiled into a real JavaScript RegExp object. With the "g" (global) flag checked, every match in the text is found and highlighted; without it, only the first match is shown — matching exactly how RegExp.exec and String.match behave in real code.

Regex Tester Example

The pattern \d+ with the "g" flag checked highlights every run of digits in the test string — "12345", "2024", "01", "15", and "987654321" in the default example.

How to Use the Regex Tester

Step 1

Enter a regular expression pattern (without the surrounding slashes).

Step 2

Check the flags you want: g, i, m, or s.

Step 3

Enter or edit the test string.

Step 4

Matches highlight live, with a list of each match's position and any capture groups below.

Benefits

  • Highlights matches live as you type, with no need to run code to test a pattern.
  • Shows capture groups for each match, not just the full match text.
  • Processes everything locally in your browser — nothing is sent anywhere.

Common Regex Tester Scenarios

Scenario 1

Debugging a regular expression before using it in code.

Scenario 2

Checking whether a pattern correctly matches (or avoids) specific example inputs.

Scenario 3

Learning how flags like g, i, m, and s change matching behavior.

Understanding Your Result

Highlighted text in the test string shows exactly what your pattern matches. The match list below shows each match's starting index and any capture groups — "undefined" for an optional group that didn't participate in that match.

Tips

  • Check the g flag to see every match instead of just the first one.
  • Use the i flag for case-insensitive matching, like matching "Hello" and "hello" the same way.
  • Parentheses in your pattern create capture groups — check the match details list to see what each group captured.

Common Mistakes

  • Forgetting the g flag and wondering why only the first match highlights.
  • Including the surrounding slashes (e.g. /\d+/g) in the pattern field — only the pattern itself goes there, flags go in the checkboxes.
  • Using . expecting it to match newlines — check the s flag if you need that.

Frequently Asked Questions

Is my text sent anywhere?

No, all matching happens locally in your browser using JavaScript's built-in RegExp — nothing is sent to a server.

What regex flavor does this use?

Standard JavaScript (ECMAScript) regular expressions, the same engine used by browsers and Node.js — syntax may differ slightly from PCRE, Python, or other regex flavors.

Why does my pattern show an 'Invalid regex' error?

JavaScript couldn't compile your pattern — check for unescaped special characters or unbalanced parentheses/brackets.

What does a capture group showing 'undefined' mean?

That group was optional (e.g. using ? or an alternation) and didn't participate in that particular match.

Does this support regex flags like global or case-insensitive?

Yes — check for flag options (like g for global, i for case-insensitive) in the tool's interface, which change how matches are found across your text.

What's the difference between a capture group and the full match?

The full match is the entire text matched by your pattern, while capture groups (defined with parentheses) extract specific sub-portions of that match for separate use.

Can I test multiline text against my pattern?

Yes — paste multiline text into the input, and depending on whether the multiline flag is enabled, ^ and $ will match either the start/end of the whole string or the start/end of each line.

Why does my regex match more or less than I expect?

Common causes include greedy vs. lazy quantifiers matching more text than intended, or missing escape characters for special regex symbols that need to be treated as literal characters.

Is JavaScript regex the same as regex in Python or other languages?

The core syntax is very similar across languages, but there are differences in specific features like lookbehind support or named groups, so a pattern tested here should be re-verified if used in a different language's regex engine.

Important Information

Pattern matching runs locally in your browser using JavaScript's RegExp and is never sent to a server.

Last updated: August 1, 2026