What is the Regex Tester?
ToolMint's Regex Tester evaluates JavaScript-compatible regular expressions against sample text in your browser. It shows the match count, highlighted matches, indexes, numbered and named capture groups, and an optional replacement preview.
The evaluation runs in a dedicated Web Worker. Patterns, test strings, replacement text and results stay in the current browser tab; they are not uploaded or included in analytics. The tool is useful for checking a pattern before placing it in application code, but you should still test it against representative inputs in your own project.
How to test a regular expression
- Enter a JavaScript-compatible pattern such as
(cat|dog)\\s+\\d+. - Add flags such as
g,i,morswhen the pattern needs them. - Paste plain-text sample data into Test string.
- Add a replacement string if you want to preview JavaScript replacement behavior.
- Select Test regex, then inspect the matches and output.
The pattern is limited to 2,048 characters, the test string to 200,000 characters, and the result to 1,000 matches. Evaluation has a two-second time budget. These limits keep normal testing responsive, but no limit can guarantee that every pathological expression will complete instantly.
JavaScript regex syntax
This tool follows the JavaScript RegExp implementation available in the current browser. It is not a universal PCRE, Python or .NET tester. Newer syntax, flags, lookbehind and Unicode property escapes depend on browser support.
Common examples include:
| Pattern | Use | Flags |
|---|---|---|
\\b(\\w+)\\s+\\1\\b |
Find a repeated word | gi |
^name=(?<value>.+)$ |
Capture a value on each line | m |
(\\d{4})-(\\d{2})-(\\d{2}) |
Capture date components | g |
^https?:// |
Check an HTTP or HTTPS prefix | i |
Use g when you need all matches rather than the first match. Use m when ^ and $ should apply to individual lines. Use s when supported and a dot should include line terminators. Duplicate or unsupported flags are rejected.
Matches and capture groups
Each match includes its text, starting index and length. Parenthesized groups are returned separately, and named groups retain their names. A valid expression can have zero matches; that means the pattern parsed successfully but did not find the requested structure in the supplied text.
The highlighted preview is rendered as text. Sample text that looks like HTML, an event handler or a script is not inserted as executable markup. Copy actions are available only after a valid evaluation and copy plain-text summaries or the replacement preview.
Replacement previews
Enter a replacement string to preview JavaScript String.prototype.replace semantics. References such as $1 and $<name> can use captured groups. The preview uses the selected flags, so a non-global pattern replaces the first match while a global pattern can replace every match.
Treat the preview as a check of JavaScript behavior, not as a guarantee for another regex flavor. Confirm the result with tests in the application that will run it.
Common mistakes
- Copying a PCRE, Python or .NET pattern without adapting its syntax for JavaScript.
- Forgetting
gwhen expecting every occurrence. - Forgetting that a backslash must be escaped again when a regex is written inside a JavaScript string literal.
- Assuming a valid expression must match every test string.
- Adding a broad nested quantifier without testing a long non-matching input.
Privacy and safety
Regex evaluation is local and does not call an API. The Worker is terminated after completion, failure, timeout, replacement input, reset or unmount. Analytics records only generic operation and outcome information; it does not receive the pattern, flags, test string, replacement, matched text, groups or error details.
The tool uses bounded inputs and results to reduce browser resource use. It does not promise protection from every expensive expression, so avoid pasting highly sensitive data and test potentially complex patterns with care. Verify generated replacement output before using it in production.
Related developer tools
Use the JSON Formatter to inspect structured JSON, the JSON Schema Validator to check a JSON contract, the JSONPath Tester to query nested JSON, or the Text Diff Checker to compare sample outputs.
Sources
- RegExp - JavaScript | MDN
- RegExp.prototype.exec() - JavaScript | MDN
- String.prototype.replace() - JavaScript | MDN
The FAQ section below is generated from the ToolMint registry so visible answers and FAQ structured data remain synchronized.