Regex Tester
Test regular expressions live. Matches are highlighted as you type.
What Is a Regex Tester?
Regular expressions are the most powerful text-search tool ever packed into one line — and the least forgiving. A regex tester lets you build a pattern against real text and see the matches light up as you type, turning the usual write-run-debug misery into a live conversation. Enter your pattern, paste a test string, and the matches highlight instantly. A built-in library of common patterns — email, URL, phone number, date (YYYY-MM-DD), IPv4 address — gives you working starting points for the patterns everyone eventually needs.
Regex earns its reputation honestly: a pattern like \b[A-Z][a-z]+\b is compact to the point of opacity, yet it encodes "capitalized words" perfectly. The skill is not memorizing symbols but developing the loop — hypothesize a pattern, test it against examples that should match and examples that should not, refine. That loop is exactly what a tester accelerates, and the edge cases you discover here are bugs you do not ship.
How to Use the Regex Tester
- Type your regular expression into the pattern field (without the surrounding slashes used in code).
- Paste or type your test text into the test string field.
- Watch the matches highlight in the results area as you refine the pattern.
- Or start from the "Common patterns" menu — load Email, URL, Phone, Date, or IPv4, then adapt it to your needs.
A Five-Symbol Starter Kit
Most practical patterns are built from a small kit. "." matches any character; "*" repeats the previous item zero or more times; "+" one or more; "?" makes it optional. Character classes in brackets — [0-9], [a-z], [^0-9] (the ^ negates) — match one character from the set, and shorthand classes compress the common ones: \d digit, \w word character, \s whitespace (capitals negate: \D, \W, \S). Anchors ^ and $ pin to start and end; \b marks a word boundary. Combine them: \d{3}-\d{4} finds phone fragments, ^\d+$ validates "digits only." With these few pieces, the famous patterns — emails, dates, IPs — stop looking like sorcery and start looking like Lego.
Testing Discipline
- Always include negative tests: strings that must NOT match. Most regex bugs are over-matching, not under-matching.
- Test boundaries: empty string, very long input, and the character just outside your intended class (the "." in an IP, the "+" in an email).
- Remember this tester uses JavaScript's regex flavor; Python, PCRE, and others differ slightly in features and escapes.
Why does my pattern match things it shouldn't?
Usually an unescaped dot ("." matches every character, so example.com also matches exampleXcom — write example\.com), or a missing anchor (patterns match anywhere in the string by default; wrap with ^...$ to demand a whole-string match). Greediness is the third classic: .* swallows everything between the first and last possible endpoints — add ? for the lazy version (.*?) or use a negated class like [^"]* for quoted text.
What are regex flags, and which does this tester use?
Flags modify how a pattern behaves: g (global — find all matches, not just the first), i (case-insensitive), m (multiline — ^ and $ match at line breaks). Testers typically enable global matching so every match highlights. In your own JavaScript code you add flags after the closing slash (/pattern/gi); in other languages they are set as options — the pattern itself usually ports unchanged.
Can regex validate an email address properly?
Properly is doing heavy lifting in that sentence. The full official standard for email addresses is so permissive that the complete regex runs to thousands of characters and still misses the real question — whether the mailbox exists. Practical patterns like the common-pattern preset catch typos and structural errors, which is what form validation actually needs; deliverability is proven by sending a confirmation email, not by a cleverer pattern.
How do I match a literal special character like $ or ( ?
Escape it with a backslash: \$, \(, \., \\. The characters with special regex meaning are . * + ? ^ $ { } [ ] ( ) | \ — inside a character class most lose their powers (except ], ^, and the backslash itself). Forgetting to escape the dot in file extensions and IP addresses is the single most common regex bug in production code.