Regex Tester (JavaScript)
Test JavaScript regular expressions against your text with live match highlighting and an optional replacement string.
Runs on your browser's native RegExp engine — nothing is uploadedHow to use
Paste your sample text into the input area, then type a JavaScript regular expression into the pattern field and choose any flags you need. Click Test to see every match highlighted in the text, along with a count and the captured groups for each match. Add a replacement string to preview what a substitution would produce before you run it in code. Because the tool uses your browser's native RegExp engine, the result matches exactly what your front-end or Node.js code would do, so you can debug patterns against the same engine that runs in production.
Example
Pattern: \d+ Text: abc123def456 Matches: 123, 456
FAQ
Which engine is used?
Your browser's native JavaScript RegExp, so behavior matches front-end code.
Are flags required?
No. Flags default to "g" (global); change them to "i" for case-insensitive or "m" for multiline.
What do the common flags mean?
g finds all matches instead of just the first, i ignores letter case, m treats ^ and $ as line boundaries, s lets the dot match newlines, and u enables full Unicode mode. Leave flags empty for a single case-sensitive match.
Why does my pattern throw an error?
An invalid pattern such as an unclosed group or bracket shows the JavaScript error message from the RegExp engine, so you can fix the syntax directly.
Can I test lookahead and named groups?
Yes. Modern browsers support lookahead (?=), negative lookahead (?!), lookbehind, and named capture groups (?<name>), so those behave exactly as they would in current JavaScript.
How do I capture part of a match?
Wrap the part you want in parentheses, such as "(\d+)" to capture digits. Each pair of parentheses becomes a numbered group shown in the results, and you can reference it in a replacement as $1, $2 and so on.
What is a non-capturing group?
Write "(?:...)" to group alternatives without creating a capture. Use it when you need grouping for precedence, such as "cat|dog" inside a larger pattern, but do not need to extract that piece separately.
How do I match a literal special character?
Characters such as . * + ? ( ) [ ] { } | ^ $ have special meaning, so put a backslash before one to match it literally. For example "\." matches a period, while "." alone matches any single character.