Regex looks like keyboard smashing but is only ~15 symbols. Here are the ones that cover daily work.
The symbols
\d digit \w letter/digit/_ \s whitespace . anything
+ one or more * zero or more ? optional
^ start $ end [abc] any of [^abc] none of {3} exactly 3
(x|y) x or y \. literal dot (escape specials)Copy-paste validations
/^\d{6}$/ // Indian pincode
/^[6-9]\d{9}$/ // Indian mobile
/^[\w.+-]+@[\w-]+\.[\w.]{2,}$/i // email (pragmatic)
/^[A-Za-z0-9_]{3,16}$/ // usernameThe three JS methods
/\d+/.test("abc123") // true โ validation
"abc123def".match(/\d+/g) // ["123"] โ extraction
"2026-07-02".replace(/-/g, "/") // replaceNamed groups โ readable extraction
const m = "2026-07-02".match(/(?<y>\d{4})-(?<mo>\d{2})-(?<d>\d{2})/);
m.groups.y // "2026"Sanity rule: if the regex takes longer than 5 minutes, parse in code instead. Test patterns live at regex101.com โ it explains every symbol as you type.
โ All Articles