.* Regex Tester
Test JavaScript regular expressions against sample text, inspect matches and capture groups, highlight results, and preview replacements without sending your pattern or text to a server.
Test a JavaScript Regular Expression
/slashes/. Maximum pattern length: 2,000 characters.$& for the full match and $1, $2 for capture groups.Highlighted Matches
Match Details
Replacement Preview
What Is a Regex Tester?
A regex tester helps you check whether a regular expression matches the text you expect. Regular expressions, often shortened to regex or RegExp, describe text patterns that can be used to search, validate, extract, split or replace parts of strings.
This ToolStrive tester uses the browser's native JavaScript RegExp engine. That matters because regex syntax and features can differ between JavaScript, PCRE, Python, .NET and other regex flavors.
How to Use the Regex Tester
- Enter a JavaScript regular expression pattern without the surrounding slash characters.
- Select any flags you need, such as g for all matches or i for case-insensitive matching.
- Paste the text you want to test.
- Click Test Regex to view highlighted matches, positions and capture groups.
- Optionally enter replacement text and click Preview Replacement to see the transformed output.
The tool caps test text at 100,000 characters and patterns at 2,000 characters. This keeps the page responsive for normal testing while still allowing realistic development examples.
JavaScript Regex Flags
- g β global: finds all matches instead of stopping after the first.
- i β ignore case: treats uppercase and lowercase letters as equivalent where applicable.
- m β multiline: changes how
^and$work across multiple lines. - s β dotAll: allows
.to match line-break characters. - u β Unicode: enables Unicode-aware pattern behavior.
- d β indices: requests match index information from supporting browsers.
- v β Unicode Sets: provides newer Unicode set features where the browser supports them.
- y β sticky: requires matching to begin exactly at the current regex position.
The tester checks flag support in your browser and disables a flag when the current engine does not support it. Because JavaScript treats u and v as alternative Unicode modes, they cannot be enabled together.
Regex Examples
([\w.+-]+)@([\w.-]+\.[A-Za-z]{2,})Use g to find multiple addresses and inspect the captured username and domain.
\b\d+\bMatches sequences of digits that appear as whole word-like tokens.
^ERROR.*$Use the gm flags to scan a multi-line log and match each relevant line.
(\d{4})-(\d{2})-(\d{2})Captures year, month and day separately for text that follows a YYYY-MM-DD shape.
Capture Groups and Replacement
Parentheses create capture groups. For example, the pattern (\w+)@([\w.-]+) can capture the text before @ as group 1 and the text after it as group 2. The Match Details section shows capture values for each result.
Replacement strings can reuse those captures. In JavaScript replacement syntax, $& means the complete match, while $1, $2 and later numbers refer to capture groups. When the global flag is disabled, replacement normally affects only the first match.
Safety, Limits and Regex Performance
Some regular expressions can take an unexpectedly long time on certain inputs because of excessive backtracking. Instead of running the test directly on the page's main JavaScript thread, ToolStrive performs regex execution inside a temporary Web Worker and terminates it when it exceeds the time limit.
The match-detail list is also capped for display. If a pattern creates hundreds of results, the total count can still be reported while only the first set of matches is rendered to keep the interface responsive.
Frequently Asked Questions
Which regex flavor does this tool use?
It uses JavaScript's native RegExp implementation in your browser. A pattern written specifically for PCRE, Python or another engine may need changes before it works in JavaScript.
Why does my regex only return one match?
Enable the g global flag when you want JavaScript to continue finding matches after the first one.
Why are some flags disabled?
The tester detects support in the current browser. A newer flag can be disabled when that browser's JavaScript engine does not implement it.
Is my test text uploaded?
No. The main matching and replacement operations run locally in your browser. ToolStrive does not need to send the pattern or test text to a server for this tool.
Can this validate every email address or URL?
Regex can check a text shape, but complete validation rules for real-world addresses, URLs and other formats can be more complex than a short pattern. Use application-specific validation when correctness is critical.
Related Developer Tools
Regex is often used alongside structured-data and encoding tools during debugging. You can move between these utilities without leaving the Developer Tools section.