regexregular expressionsjavascriptdevelopment
Regular expressions: a complete guide with examples
What is regex, how to read patterns, 10 ready-made regulars for validating email, phone numbers, URLs and dates.
Published February 23, 2026·Time to read: 8 min
What are regular expressions?
Regular Expressions (regex, regexp) is a powerful language for searching and replacing text using a pattern. Used in JavaScript, Python, PHP, bash and most other languages.
Basic syntax
| Symbol | Meaning | Example |
|---|---|---|
| --- | --- | --- |
| `.` | Any character | `a.c` → "abc", "a1c" |
| `*` | 0 or more | `ab*c` → "ac", "abc", "abbc" |
| `+` | 1 or more | `ab+c` → "abc", "abbc" |
| `?` | 0 or 1 | `ab?c` → "ac", "abc" |
| `^` | Start of line | `^Hello` |
| `$` | End of line | `World$` |
| `\d` | Digit | `\d{3}` → "123" |
| `\w` | Letter/number/_ | `\w+` |
10 ready-made patterns
// Email
/[\w.-]+@[\w.-]+\.\w+/
// RF phone
/\+7[\s(]?\d{3}[\s)]?\d{3}[-\s]?\d{2}[-\s]?\d{2}/
// URL
/https?:\/\/[^\s]+/
// IPv4
/\b(?:\d{1,3}\.){3}\d{1,3}\b/
// Date DD.MM.YYYY
/\d{2}\.\d{2}\.\d{4}/
// Cyrillic
/[A-Yaa-yayo]+/
// Hex color
/#[0-9A-Fa-f]{6}/
// Postal code of the Russian Federation
/\d{6}/
// INN (10 digits)
/\d{10}/
// UUID
/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/ Test your regex in our interactive tool with match highlighting.