Developer Tools
Regex Tester
Test JavaScript regex patterns and inspect matches and capture groups.
Uses the browser's JavaScript RegExp engine. For responsiveness, patterns are limited to 500 characters and test text to 100,000 characters. Avoid testing untrusted complex patterns against very large text.
Matches
2 matches
ada@example.comIndex 8Group 1:adaGroup 2:example.comuser:adadomain:example.comgrace@example.orgIndex 27Group 1:graceGroup 2:example.orguser:gracedomain:example.org
About This Tool
Regular expressions are compact pattern descriptions used for searching, validation, parsing, and text transformation. Small syntax changes can alter what a pattern matches, especially once flags, anchors, character classes, quantifiers, and capture groups are involved. This tester runs a pattern against your sample text with the browser's JavaScript RegExp engine and lists the exact matched text, starting index, numbered capture groups, and named capture groups. It is intended for learning and debugging JavaScript-compatible expressions without sending the pattern or test text to a server.
How To Use It
- Enter a JavaScript regular expression pattern without surrounding /slashes/.
- Add JavaScript flags such as g for repeated matches, i for case-insensitive matching, or m for multiline anchor behavior.
- Paste or type representative test text. Results update locally and show each match's starting index and capture groups.
- Test realistic edge cases before using a regex in production. A successful sample does not prove a pattern is safe or correct for every possible input.
Examples
Whole words
Pattern \bcat\b with flags gi matches Cat and cat as complete words while avoiding characters embedded inside a longer word.
Named email parts
Pattern (?<user>[a-z]+)@(?<domain>[a-z]+\.[a-z]+) with gi can expose the user and domain portions as named groups for simple controlled examples.
Multiline starts
Pattern ^TODO: with flags gm can find lines that begin with TODO:. The m flag changes how ^ and $ behave across line boundaries.
Useful Notes
JavaScript regex syntax
The tool uses the browser's RegExp implementation, so syntax and supported features follow the JavaScript engine in your browser. Enter the pattern body only; flags have their own field. Features available in another regex flavor such as PCRE, Python, Java, or .NET may differ or be unsupported.
Global and sticky matching
Without g or y, JavaScript RegExp.exec returns the first match only. With g, the tester continues through the text and reports repeated matches. Sticky y matching requires the next match to begin at the engine's current lastIndex, so it behaves differently from a general search.
Capture groups
Parentheses capture portions of a match unless they are non-capturing. Numbered groups appear in order, while (?<name>...) creates a named group when supported. A group can be undefined when its branch did not participate in a particular match.
Flags change semantics
Common flags include g for global matching, i for case-insensitive matching, m for multiline anchors, s for dotAll, and u for Unicode-aware parsing. Modern engines may also support d, v, and y. Duplicate or unsupported flags are rejected rather than silently ignored.
Performance and ReDoS risk
Some regular expressions can require extreme backtracking on specially shaped input. Browser JavaScript does not provide a portable way to interrupt a RegExp that is already executing. This tool limits pattern and input sizes, but those limits cannot guarantee that every pattern completes quickly. Do not paste untrusted pathological patterns or rely on this page as a regex security analyzer.
Validation is more than a regex
Regex can check textual shape, but many real values also need semantic rules. Email addresses, URLs, dates, identifiers, and structured formats can have standards or context that a short pattern does not fully represent. Prefer purpose-built parsers when correctness depends on those rules.
FAQ
Should I include /slashes/ around the pattern?
No. Enter only the pattern body. Put flags such as g or i in the separate Flags field.
Why do I see only one match?
Add the g flag when you want JavaScript to continue searching for additional matches. Without g or y, the tester intentionally reports the first match.
Can a regex freeze the page?
A pathological backtracking expression can take a long time in JavaScript, and a running RegExp cannot be reliably cancelled in all browsers. Input limits reduce exposure but do not eliminate this risk, so avoid untrusted complex patterns.
Is my test text uploaded?
No. Matching is performed by the browser code on this page; the tool does not need an API or backend for the regex operation.
Related Tools
Text Difference Checker
Compare two texts and find line-by-line changes.
Word & Character Counter
PopularInstant word, character, line, and reading-time counts.
JSON Formatter & Validator
PopularValidate JSON, pretty-print it, minify it, and inspect JSON paths.
URL Parser & Inspector
Inspect URL components and query parameters.