MetaForge Tools

Regex Tester

Test JavaScript regular expressions in real time. Highlight matches, inspect capture groups, switch flags, and start from practical presets.

Last updated:

Expression and sample text

Supports JavaScript flags: d, g, i, m, s, u, v, y.

Local only
//

Flags

Common presets

Result preview

2 matches

Highlighted text

2 matches
support@metaforge.cn hello@example.com not-an-email

Match details

Match #1

Range: 0-20
Full matchsupport@metaforge.cn

Capture groups

$1support
$2metaforge.cn

Match #2

Range: 21-38
Full matchhello@example.com

Capture groups

$1hello
$2example.com

Test JavaScript regular expressions against sample text

A regular expression can match more or less text than expected. Try a pattern and flags against realistic sample input, then inspect each match and capture group before putting the expression into code.

How to use it

  1. Paste a sample that includes cases you expect to match and cases you expect to reject.
  2. Enter a JavaScript pattern and choose flags such as g, i, or m.
  3. Inspect highlighted matches and numbered or named capture groups; revise the pattern until the results match your examples.

Useful examples

  • Extract IDs from log lines while checking that unrelated numbers are ignored.
  • Test a multiline heading pattern before using it in a text-processing script.
  • Compare case-sensitive and case-insensitive matching on the same sample.

This tool uses JavaScript RegExp syntax. A pattern accepted by another engine, such as PCRE or Python, may behave differently. The preview shows at most 500 matches.

Frequently asked questions

Which regex engine does this use?

Patterns are evaluated by the JavaScript RegExp engine in your browser.

Can I inspect capture groups?

Yes. Match details include numbered groups and named groups when your pattern defines them.

Why do I see only one match?

Add the g flag to search for all matches. Without it, JavaScript returns the first match.

Is my sample text uploaded?

No. Matching runs locally in your browser.

Are all matches displayed?

The interface limits the preview to the first 500 matches so very broad patterns remain usable.

Related tools

Text Diff

Compare text before and after a pattern-based edit.

JSON Formatter

Inspect structured sample data separately from regex matching.