Test regular expressions with real-time matching, highlighting, and group capture. Debug and refine your regex patterns instantly.
See matches highlighted instantly as you type your regex pattern or test string. No need to press a button — results update automatically. Captured groups and match positions are displayed for every match.
All regex matching runs entirely in your browser using JavaScript. Your patterns and test strings are never sent to any server. Bookmark this page and use it offline once cached.
Test regex replacements with backreferences like $1, $2, and named groups. Preview the replaced output in real time before applying it to your code.
Validate email addresses with regex patterns. Test common email patterns like [\w.+-]+@[\w-]+\.[\w.]+ against your data. Our highlighter shows exactly which parts of your string match, so you can refine your pattern for edge cases.
Match US and international phone numbers with regex. Test patterns for formats like (555) 123-4567, 555-123-4567, or +1-555-123-4567. Use our quick-fill buttons to load common phone patterns instantly.
Extract and validate URLs from text using regex. Test patterns for HTTP/HTTPS links, domains, and paths. Our tool highlights all matched URLs and displays captured groups for protocol, domain, and path segments.
Use regex to clean log files, parse CSV data, or extract information from structured text. Test replacement patterns with backreferences to reformat dates, swap names, or strip unwanted characters from your data.
Regular expressions use special characters and sequences to define patterns. Here's a quick reference for the most commonly used regex syntax elements.
. — Matches any character except newline (unless s flag is set)\d — Matches any digit (0-9)\w — Matches any word character (a-z, A-Z, 0-9, _)\s — Matches any whitespace character (space, tab, newline)^ — Matches the start of the string (or line with m flag)$ — Matches the end of the string (or line with m flag)* — Matches 0 or more of the preceding element+ — Matches 1 or more of the preceding element? — Matches 0 or 1 of the preceding element{n,m} — Matches between n and m occurrences[abc] — Character class: matches a, b, or c(abc) — Capturing group(?:abc) — Non-capturing groupa|b — Alternation: matches a or b\b — Word boundary\b\w+@\w+\.\w+\b — and pick flags: g to find every match rather than just the first, i for case-insensitivity, m to make ^ and $ work per-line.Character classes — \d (digit), \w (word character), \s (whitespace), [a-f0-9] (custom set). Quantifiers — + (one or more), * (zero or more), ? (optional), {2,4} (a counted range). Anchors — ^ and $ pin a match to the start or end, the difference between "contains a number" and "is a number". Groups — ( ) capture parts of the match for extraction or backreference. Alternation — cat|dog matches either. Nearly every practical pattern is just these five combined.
The classic beginner trap is greediness: quantifiers match as much as possible, so ".*" applied to say "hi" and "bye" grabs from the first quote to the last. Adding ? makes it lazy — ".*?" stops at the first closing quote. Watching this happen live in the tester teaches it faster than any tutorial. For a structured walkthrough from zero, read our regular expressions beginner's guide.
Email (pragmatic): ^[\w.+-]+@[\w-]+\.[\w.]+$
URL: https?://[^\s]+
Date (YYYY-MM-DD): ^\d{4}-\d{2}-\d{2}$
Time (24h): ^([01]\d|2[0-3]):[0-5]\d$
Hex color: ^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
Trim whitespace: ^\s+|\s+$ (replace with "")
Duplicate words: \b(\w+)\s+\1\b
Paste any of these into the tester with your own data to see how they behave — and where they break. A pragmatic email pattern, for instance, deliberately rejects some technically-valid addresses; whether that trade-off is right depends on your application, and the only way to know is to test against real samples.
JavaScript (ECMAScript), since it runs in your browser. Core syntax is shared with Python, Java, and PCRE; the differences appear in advanced features like lookbehind and named groups, so verify those in your target language too.
Usually string escaping: in code, backslashes inside quoted strings need doubling ("\\d+"), or a raw string in Python (r"\d+"). Second most common: a missing g flag, so only the first match is replaced.
By design, . matches everything except newlines. Use the s (dotAll) flag, or match whitespace explicitly with [\s\S].
No — matching runs locally in your browser, so testing against real logs or customer data doesn't expose it.
Use a simple pattern to catch obvious typos, then confirm with a verification email — the only real proof an address works. Fully RFC-compliant email regexes run to hundreds of characters and still can't tell you whether the mailbox exists.