Regex Tester
Test regular expressions against text and see every match highlighted live.
๐ฏTest patterns against real text, live
Write a regular expression, paste sample text, and watch every match highlight instantly โ with flags for case-insensitive, global, and multiline matching. Regex is the closest thing programming has to a superpower, and the only way to learn it is to watch patterns hit (and miss) real text.
๐งฎThe 20% of regex you'll use 80% of the time
Anchors pin positions (^ start, $ end), brackets pick alternatives ([aeiou]), braces count ({2,4}), and parentheses capture groups. Everything else is combinations of these.
^\d{6}$ matches an Indian PIN code โ exactly six digits, nothing more. \b\w+@\w+\.\w{2,}\b catches simple email shapes in a paragraph.๐กRegex habits that prevent pain
- Build incrementally: get \d+ matching first, then add anchors and groups.
- Test the failures too โ a pattern that matches everything is worse than none.
- Escape literal dots: . means 'any character'; \. means an actual full stop.
- Greedy vs lazy: .* grabs the longest match, .*? the shortest โ the classic HTML-tag trap.
- For validation in real apps, anchor with ^ and $ or partial garbage will pass.
๐ก Frequently Asked Questions
What is a regular expression?+
A compact pattern language for finding and validating text: \d{6} means 'six digits', ^[A-Z] means 'starts with a capital'. Every major programming language and editor supports it.
What do the g, i, and m flags mean?+
g (global) finds every match instead of stopping at the first; i makes matching case-insensitive; m lets ^ and $ match at each line's start/end instead of only the whole text's.
Why does my dot match everything?+
In regex, . is a wildcard for any character. To match a literal full stop, escape it as \. โ the most common beginner slip (a.b matches 'axb', not just 'a.b').
How do I match an email or phone number?+
Simple shapes work for finding: \b\w+@\w+\.\w{2,}\b for emails, \d{10} for Indian mobiles. Full RFC-compliant validation is famously gnarly โ for real apps, keep the regex simple and verify by sending a message.
Is my test text uploaded?+
No โ matching runs in your browser's JavaScript engine. Paste logs or private data freely; nothing leaves the page.