Regex Tester
Test, debug, and evaluate your regex patterns instantly with real-time highlighting and match details.
About the Tool
The building blocks
A regular expression is a compact language for describing patterns in text. The pieces you reach for most often are character classes, anchors and groups. A class like \d matches any digit and \w any word character; the anchors ^ and $ pin a match to the start and end of the line; and parentheses create capture groups so you can pull part of a match back out.
Quantifiers and greedy matching
Quantifiers say how many times something may repeat: * means zero or more, + one or more, ? optional, and {2,4} a specific range. By default quantifiers are greedy - they grab as much text as possible - which is the single most common cause of a pattern matching far more than you intended. Add a ? after the quantifier to make it lazy, matching as little as possible instead.
Flags that change everything
- g - global: find every match, not just the first one.
- i - case-insensitive matching.
- m - multiline, so ^ and $ match at every line break.
- s - dot-all, letting the dot match newline characters too.
Patterns you can reuse
Basic email: ^[^@\s]+@[^@\s]+\.[^@\s]+$
SA mobile: ^(?:\+27|0)[6-8][0-9]{8}$
SA ID (13): ^\d{13}$Test these against both real and deliberately malformed input in the box above before trusting them in production. A validation pattern is a starting point, not a guarantee - matching the shape of an email address or ID number does not prove the value actually exists.