How to test a regular expression
Writing a regular expression is easier when you can see what it matches. Type a pattern and a test string and the matches light up.
Step by step
- Type a pattern. Enter the regular expression without slashes, then choose flags.
- Paste test text. Matches are highlighted as you type.
- Check groups and replace. See capture groups and preview a replacement.
Tips for better results
- Use the g flag to find all matches, and i to ignore case.
- Capture groups appear in the table below the test string.
- Patterns that take too long are stopped after 2 seconds so the page stays usable.
Limits to know
- Formats: JavaScript regular expressions
- Size: Limited by browser memory
- Notes: Uses the JavaScript regex engine. Other languages (PCRE, Python, .NET) have small differences. Shows up to 1,000 matches.
At a glance
| Tool | Regex Tester |
|---|---|
| Category | Developer Tools |
| Works with | JavaScript regular expressions |
| Size limit | Limited by browser memory |
| Where it runs | In your browser tab; your input is not uploaded |
| Cost | Free, no sign-up |
Frequently asked questions
Which regex flavour is used?
JavaScript (ECMAScript), the same as the RegExp object in your browser.
Why is my pattern stopped?
Some patterns, for example nested repeats like (a+)+, can take exponential time. The tester stops them after 2 seconds.
If something does not work
- The result says a value is invalid. Check that every field has a number in the allowed range; the message names the field.
- The numbers look different from another calculator. Rounding, rate and date conventions differ between calculators. Compare the assumptions shown with the result.
- The page does not update. Reload it and try again; if it still fails, report it.
- Is the answer advice? No. Results are estimates for general information.
Still stuck? Use Report a Problem and tell us the tool, your browser and what happened, or read the Help Center.
Related tools and guides
- JSON Formatter: Format, indent, sort and minify JSON. Invalid JSON is reported with the line and column of the problem. Read the guide
- JSON Validator: Check whether your JSON is valid. If it is not, see the exact line and column and a plain-English reason. Read the guide
- HTML Formatter: Indent and tidy HTML. Inline tags stay on the line, and embedded CSS and JavaScript are formatted too. Read the guide
More tools like this are in Developer Tools, or browse all tools.