Test JavaScript regular expressions with sample text
Use this tool when you need to check what a JavaScript regex matches before putting it into frontend, Node.js, or TypeScript code.
Paste sample text, enter the pattern without wrapping slashes, choose flags, then review matches, groups, and replacement output.
What each result means
- Highlighted matches shows where the pattern matched inside the sample text.
- Matches and groups lists match ranges, numbered groups, and named groups.
- Replacement output previews JavaScript
String.replace()with your replacement string. - Copy match JSON copies structured match data. Copy replacement copies the replacement preview text.
- Copy URL copies the current pattern, flags, replacement, and sample text in the URL hash.
Supported flags
| Flag | Name | Effect |
|---|---|---|
g | Global | Find all matches instead of only the first one. |
i | Ignore case | Match letters without case sensitivity. |
m | Multiline | Make ^ and $ work per line. |
s | DotAll | Let . match line breaks. |
u | Unicode | Use Unicode-aware matching rules. |
y | Sticky | Match only from the current JavaScript lastIndex. |
Limits
- This is a JavaScript
RegExptester, not a PCRE, Python, Java, SQL, or .NET regex tester. - Sample text and collected matches are capped to keep the page responsive.
- Some obvious nested-quantifier patterns are blocked, but this is not a full ReDoS analyzer.
- JavaScript does not provide a synchronous timeout for one regex execution.
- URL hashes can include pasted sample text. Remove private logs or secrets before sharing a copied URL.
Frequently Asked Questions
Which regex syntax does this page use?
It uses JavaScript RegExp syntax. Use it for browser, Node.js, and TypeScript regex work. Patterns written for PCRE, Python, Java, SQL, or .NET may behave differently.
Why do I only see one match?
Add the g flag to collect all matches. Without g, JavaScript normally returns the first match.
Can I use named groups in replacements?
Yes. Named groups such as (?<level>ERROR|WARN) appear in match details and can be reused in replacement text as $<level>.
What is the difference between Copy match JSON and Copy replacement?
Copy match JSON copies match ranges and groups as JSON. Copy replacement copies the text produced by the replacement preview.
Can this catch unsafe backtracking patterns?
Only partially. The tool blocks some obvious nested-quantifier patterns and caps input size, but it is not a full ReDoS analyzer.