tools / developer
Regex Tester
Test regular expressions with live highlighting.
//
TEST STRING
QUICK REFERENCE
.any character except newline\ddigit [0-9]\wword char [a-zA-Z0-9_]\swhitespace^start of string/line$end of string/line*0 or more+1 or more?0 or 1 (optional){n,m}between n and m times(abc)capture group(?:abc)non-capture groupa|ba or b[abc]character class[^abc]negated classABOUT THIS TOOL
Write a regular expression and paste sample text to see matches highlighted in real time as you type. Supports standard flags like global (g), case-insensitive (i), and multiline (m), and shows capture groups separately from the full match so you can see exactly what a pattern extracts versus what it simply matches. A practical way to build, test, and refine patterns before dropping them into code, since regex behavior can vary subtly between languages — JavaScript, Python, and PCRE handle lookbehind, Unicode property escapes, and named groups differently — and testing against real sample text catches edge cases no amount of trial and error in production would.
HOW TO USE
- Type your regular expression pattern into the pattern field.
- Set any flags you need — global to find all matches, case-insensitive to ignore letter case, multiline for ^ and $ to match per line.
- Paste representative sample text into the test area, including edge cases you're worried about.
- Watch matches highlight live as you edit the pattern.
- Inspect capture groups separately from the overall match to confirm what your pattern would extract in code.
- Refine the pattern until it matches everything it should and nothing it shouldn't, then copy it into your codebase.
COMMON USE CASES
- A developer writing a form validator builds a pattern to check whether an email or phone number format is valid before submitting.
- Someone parsing log files crafts a regex to extract IP addresses or timestamps from unstructured text.
- A developer doing a find-and-replace across a codebase tests a pattern against sample lines before running it in their editor's regex search.
- A data engineer cleaning a messy CSV writes a pattern to strip unwanted characters or split combined fields.
- Someone debugging why a regex isn't matching in production pastes the exact failing input to see which part of the pattern is the problem.
TIPS & COMMON MISTAKES
- Greedy quantifiers like .* match as much as possible and can overshoot across unexpected text — try the lazy version .*? when you want the shortest possible match instead.
- Regex flavors differ: JavaScript only added lookbehind assertions in newer engines and lacks some PCRE features, so a pattern written for Python's re module may need tweaking to run in JavaScript.
- Special characters like ., *, +, ?, (, ), [, and \ have meaning in regex and must be escaped with a backslash if you want to match them literally.
- Without the global flag, most regex methods stop after the first match — forgetting it is a common reason "it only replaced one instance" bugs happen.
MORE QUESTIONS
- Why does my pattern work here but not in my code?
- Regex syntax differs slightly between engines — JavaScript, Python, and PCRE (used by many other languages) handle things like named groups, lookbehind, and Unicode property escapes differently, so always confirm which flavor your target language uses.
- What's the difference between a match and a capture group?
- The match is the entire substring the pattern found; capture groups, created with parentheses, let you pull out specific sub-parts of that match, like extracting just the domain from a matched email address.
- Why does my pattern match too much text?
- Greedy quantifiers (*, +, {n,}) consume as many characters as possible by default; add a ? after the quantifier (like *?) to make it lazy and match the shortest possible string instead.
- Can regex validate something complex like a fully RFC-compliant email address?
- Technically only with an extremely long, hard-to-read pattern — most real-world validators use a simplified regex for basic format checks and rely on actually sending a confirmation email to verify it's real and deliverable.
RELATED GUIDES
Regex Tutorial
Learn regular expressions from scratch with practical examples.