Regex Tester
Test regular expressions with real-time match highlighting, group capture display, and a pattern library.
Regex Tester tool
Example
Input: Pattern \d{4}-\d{2}-\d{2} on the text: Invoices due 2024-03-15 and 2024-04-01.
Result: 2 matches: 2024-03-15 and 2024-04-01
With the global flag on, every date in YYYY-MM-DD form is found and highlighted. \d matches one digit and {4} repeats it four times.
Patterns in the Common Patterns Menu
| Pattern name | Regex |
|---|---|
| Email address | [\w.+-]+@[\w-]+\.[\w.]+ |
| URL | https?://[\w\-._~:/?#[\]@!$&'()*+,;=%]+ |
| IPv4 address | \b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b |
| US phone number | \(?(\d{3})\)?[-.\s]?(\d{3})[-.\s]?(\d{4}) |
| Date (YYYY-MM-DD) | \d{4}[/-]\d{2}[/-]\d{2} |
| Hex color code | #?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})\b |
| US ZIP code | \b\d{5}(-\d{4})?\b |
| HTML tags | <[^>]+> |
| Numbers (int and float) | -?\d+\.?\d* |
Loaded exactly as listed. Adjust them to your data before using them for validation.
- Enter your regular expression pattern in the regex input field at the top.
- Toggle the desired flags (global, case-insensitive, multiline, etc.) using the flag buttons.
- Paste or type your test string in the text area below to see matches highlighted in real time.
- Review the match details panel showing matched text, capture groups, and index positions.
- Pick an entry from the Common Patterns menu to load a ready-made regex such as email or URL matching.
- Copy individual matches with their copy buttons, then use your finalized pattern in your application code.
Testing Regular Expressions in JavaScript
A regex tester shows exactly what a regular expression matches. Type a pattern and some sample text, and every match is highlighted as you type, with a count, the position of each match and what each capture group caught.
A regular expression (regex) is a small pattern language for finding text. \d{4} means four digits in a row, and [a-z]+ means one or more lowercase letters. Patterns get hard to read fast, so testing them on real samples, including text that should not match, is the quickest way to find mistakes.
The tool uses your browser's own JavaScript RegExp engine, so results match what you get in JavaScript, TypeScript and Node.js.
Four flags can be switched on or off. The g flag (global) finds every match and is on by default. The i flag ignores case, m (multiline) lets ^ and $ match at each line, and s (dotAll) lets . match line breaks. With g off, only the first match is shown. To keep the page responsive, a run stops at 1,000 matches.
The Common Patterns menu loads ready-made patterns, listed in the table below. Treat them as starting points rather than strict validators. The email pattern, for instance, accepts some addresses a mail server would reject. If a pattern has a syntax error, the engine's message is shown. For a guided tour of the syntax, open the Regex Cheatsheet. To apply a pattern to text, try Find and Replace.
Sources
Frequently Asked Questions
Related Tools
Find and Replace
Find and replace text with regular expressions, capture groups, case-sensitive matching, and a live match count.
Text and WritingJSON Formatter and Validator
Format, validate, beautify, and minify JSON data with a collapsible tree view and line-and-column error detection.
Developer ToolsRegex Cheatsheet
Interactive regex syntax reference with descriptions, examples, and a try-it-live tester for each pattern.
DevOps ToolsURL Encode and Decode
Encode special characters for URLs or decode percent-encoded strings back to readable text.
Developer Tools