Regex Tester
Live match highlighting, flags, capture groups, and replace mode.
Live match highlighting, flags, capture groups, and replace mode.
Copy and paste any of these patterns into the tester above.
| Pattern Name | Regex | Flags |
|---|---|---|
| Email address | \b[\w.+-]+@[\w-]+\.[\w.]+\b | gi |
| URL | https?:\/\/[^\s]+ | gi |
| Phone (US) | \+?1?[-.\s]?\(?[2-9]\d{2}\)?[-.\s]?\d{3}[-.\s]?\d{4} | g |
| IPv4 address | \b(?:\d{1,3}\.){3}\d{1,3}\b | g |
| Date (YYYY-MM-DD) | \b\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])\b | g |
| Hex colour | #(?:[0-9a-fA-F]{3}){1,2}\b | g |
| HTML tag | <[^>]+> | gi |
| Whitespace only lines | ^\s*$ | gm |
What is a regular expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. Used in programming and text processing, regex can match specific strings, validate formats (email, phone), extract data, and perform complex find-and-replace operations in a single line.
What do the flags mean?
g (global) finds all matches instead of stopping at the first. i (case-insensitive) matches regardless of case. m (multiline) makes ^ and $ match line boundaries. s (dotall) makes . match newline characters too. You can combine flags.
What is a capture group?
A capture group is a part of the pattern wrapped in parentheses (). When the regex matches, each group captures the text it matched. For example, in (\d{4})-(\d{2})-(\d{2}), three groups would capture the year, month, and day separately from a date string.
How do I use the replace mode?
Switch to 'Replace' mode, write your pattern in the regex box, type the replacement string below the test area, and see the result instantly. You can reference capture groups in the replacement using $1, $2, etc.
Why is my regex matching too much?
You may need quantifier constraints. .* matches any characters greedily. Use .*? for non-greedy matching, or be more specific with your character classes. For example, to match a word, use \w+ rather than .+.
How do I match a literal dot or bracket?
Escape them with a backslash: \. matches a literal dot, \( and \) match literal parentheses. The tool's pattern input treats \. as a literal dot just as JavaScript's RegExp constructor does.
More developer tools
JSON formatter, JWT decoder, Base64 encoder, cron builder and more.
Browse all toolsFeatured
Word Counter
Live word count, character count, sentence count, paragraph count, and reading time estimate as you type. Useful for blog posts, tweets, essays, and any platform with a character limit.
QR Code GeneratorPassword GeneratorJSON Formatter & DiffImage CompressorColor Picker & PalettePomodoro TimerLorem Ipsum GeneratorPercentage CalculatorBase64 Encoder / DecoderSee AllWord Counter
Live word count, character count, sentence count, paragraph count, and reading time estimate as you type. Useful for blog posts, tweets, essays, and any platform with a character limit.
QR Code Generator
Generate QR codes for URLs, plain text, WiFi credentials, or vCard contact info. Set size, foreground/background color, and error correction level. Download as PNG or SVG.
Password Generator
Generate strong passwords with configurable length (8–128), and toggles for uppercase, lowercase, numbers, and symbols. Strength meter, one-click copy. Runs entirely in the browser.
JSON Formatter & Diff
Paste raw or minified JSON to format, validate, and syntax-highlight it. Switch to diff mode to compare two JSON blobs side by side and see exactly what changed.
Image Compressor
Drag and drop JPG, PNG, or WebP images and compress them entirely in-browser using the Canvas API. Shows original vs compressed size and savings percentage. Nothing uploaded anywhere.
Color Picker & Palette
Full-featured color picker with HEX, RGB, HSL, and CMYK output. Upload an image to extract the 5 dominant colors as a palette. Copy any value with one click.