The Developer's Guide to Regular Expressions
What is Regex?
A regular expression (regex) is a pattern that describes a set of strings. Regex engines are built into every major language (JavaScript, Python, C#, Java, PHP, Go).
Basic Syntax
.— Any character except newline\d— Any digit (0–9)\w— Word character (letters, digits, underscore)\s— Whitespace^— Start of string$— End of string
Quantifiers
*— Zero or more+— One or more?— Zero or one{3}— Exactly 3{2,5}— Between 2 and 5
Real-World Examples
// Validate email
/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
// Match ISO date
/\d{4}-\d{2}-\d{2}/
Try them all in our live Regex Tester.
Found this useful? Try our Regex Tester — browser-based and free forever.