ToolsWeave

JavaScript regex utility

Regex Tester Online

Test regular expressions as you type, highlight matches, inspect numbered and named capture groups, and preview JavaScript replacements without sending your text to a server.

Your pattern and text stay in your browser.

Enter the pattern without enclosing slash characters. 50 / 2,000 characters.

JavaScript regex flags

48 / 200,000 characters

Testing regular expression…

Match highlighting

Contact [email protected] or [email protected]

Match details

Complete matches, positions, and capture groups will appear here.

Regex replacement tester

Uses JavaScript replacement syntax, including $&, $1, and named group references.

Evaluation happens in a local worker. Tests taking longer than 750 ms are stopped; no timeout can guarantee that every pathological pattern is safe.

How to test a regular expression

Enter a regex pattern

Add JavaScript regex syntax without enclosing slash characters.

Add test text

Paste the exact kind of content you expect the expression to inspect.

Choose regex flags

Enable global, case-insensitive, multiline, dotAll, Unicode, or sticky behavior as needed.

Review matches and capture groups

Check highlighting, zero-based positions, complete matches, captures, and replacement output.

What is a regular expression?

A regular expression is a compact pattern for finding text with shared structure. It can locate exact words, repeated characters, boundaries, optional parts, or groups that you want to extract. A successful syntax check does not prove that a broad real-world format—such as every valid email address—is fully validated.

Regex flags

g finds successive matches, i ignores applicable letter case, m changes line-anchor behavior, and s lets a dot include line terminators. JavaScript also provides u for Unicode-aware parsing and y for matching only at the current lastIndex.

Capturing groups

Parentheses create numbered captures, while syntax such as (?<domain>...) creates a named capture in supported JavaScript engines. The tester lists both alongside each complete match.

Regex replacement

Replacement mode uses JavaScript string replacement rules. Use $& for the complete match, $1 for the first numbered group, and $<name> for a named group.

Common regex examples

The included email, URL, IPv4, number, color, whitespace, date, and username patterns are practical test data. They intentionally remain understandable and are starting points—not standards-complete validators or security rules.

Regex Tester FAQ

What is a regex tester?

A regex tester runs a regular expression against sample text so you can inspect matches, positions, capture groups, and replacement output before using the pattern in code.

How do I test a regex online?

Enter a pattern without surrounding slashes, paste test text, and select any flags. ToolsWeave evaluates changes automatically, or you can use Test regex.

Which regex flavor does ToolsWeave use?

This tool uses the JavaScript regular expression engine in your browser. PCRE, Python, .NET, and Java have syntax and behavior differences, so patterns are not guaranteed to transfer unchanged.

What does the global g flag do?

The g flag continues searching after the first match. Without g or the sticky y flag, the JavaScript exec operation returns only the first match.

What does the case-insensitive i flag do?

The i flag makes applicable letter comparisons case-insensitive, so a pattern such as hello can match HELLO.

What are capturing groups?

Parentheses capture part of a complete match. Numbered and named captures appear in the match details and can be referenced in JavaScript replacement text.

Can I test regex replacement?

Yes. Enter replacement text using JavaScript syntax such as $&, $1, or $<name>; the replacement result updates with the test.

Is my test text uploaded to ToolsWeave?

No. Patterns, flags, replacement text, and test strings are evaluated in a local browser worker and are not included in analytics.

Related developer tools

Browse the Developer Tools collection or see all ToolsWeave tools.