Tool workspace

Regex Tester

Input

Test and debug JavaScript regular expressions. Highlight live matches, inspect capture groups and positions, and preview JavaScript replacements.

Input

Output

Loading tool

Loading tool

Developer Tools

Regex Tester

Test a JavaScript regular expression against sample text and inspect highlighted matches as you edit. Toggle supported flags, review zero-based indexes, match lengths and capture groups, and preview replacements using JavaScript syntax. Built-in examples and a quick reference help you explore common patterns.

Quick guide

How to use

Enter a JavaScript regex pattern and test text. Choose flags, inspect highlighted matches and capture groups, then enter replacement text to review the JavaScript replacement preview. Use examples and quick reference as learning aids.

Details

About this tool

JavaScript regular expressions

A regex is a pattern for finding or replacing text. This tester uses JavaScript RegExp syntax; flags, features, Unicode handling, and replacement rules can differ from PHP/PCRE, Python, and other engines.

Flags and match details

Toggle g (global), i (ignore case), m (multiline), s (dotAll), u (Unicode), and y (sticky). Inspect highlighted matches, zero-based indexes, lengths, and capture groups. JavaScript indexes and lengths use UTF-16 code units, so some visible Unicode characters occupy more than one position.

Replacement preview

Preview replacements with JavaScript conventions. $& inserts the full match, $1 and $2 insert numbered capture groups, and $$ inserts a literal dollar sign. Check the preview before using the replacement in code.

Worked example

For “Order 123-45 and item 678-90,” use (\d{3})-(\d{2}) with g to find both codes. Replacing with $2/$1 previews “Order 45/123 and item 90/678.”

Use patterns with care

Email and URL examples are starting points, not complete validators. A match does not prove an address exists or a URL is reachable. Test a pattern in the same regex engine used by your application.

Key features

Test and debug JavaScript regular expressions. Highlight live matches, inspect capture groups and positions, and preview JavaScript replacements.

How to use the tool

Enter a JavaScript regex pattern and test text. Choose flags, inspect highlighted matches and capture groups, then enter replacement text to review the JavaScript replacement preview. Use examples and quick reference as learning aids.

Guidance and limitations

Test JavaScript regular expressions online. Highlight matches, inspect capture groups and positions, preview replacements, and learn common regex syntax.

Understand the result

Test a JavaScript regular expression against sample text and inspect highlighted matches as you edit. Toggle supported flags, review zero-based indexes, match lengths and capture groups, and preview replacements using JavaScript syntax. Built-in examples and a quick reference help you explore common patterns.

Practical inputs

Examples

Find digit groups

Pattern: (\d{3})-(\d{2}); text: Order 123-45 and item 678-90; flag g

Matches: 123-45 and 678-90; capture groups are listed separately.

Reorder capture groups

Replacement: $2/$1

Order 45/123 and item 90/678

Match without case sensitivity

Pattern: toolbox; text: ToolboxShelf; flag i

A match is found regardless of letter case.

Help

Frequently asked questions

Which syntax does the tester use?

JavaScript RegExp syntax, which differs from PHP/PCRE, Python, and other engines.

What do match indexes mean?

They are zero-based positions in JavaScript UTF-16 code units. Some Unicode characters occupy multiple units.

How does replacement work?

It follows JavaScript: $& inserts the full match and $1 inserts the first capture group.

Does it validate every URL and email?

No. A simple pattern checks a match; it does not prove existence or reachability.