RegexMay 3, 2026 · 8 min read
Regular Expressions Guide for Developers
Regular expressions (regex) are powerful patterns for searching and manipulating text. This practical guide covers the most useful patterns with real-world examples.
What is Regex?
A regular expression is a sequence of characters that defines a search pattern. Regex is supported in virtually every programming language and is used for:
- Validating email addresses, phone numbers, URLs
- Finding and replacing text
- Extracting data from strings
- Parsing log files and configuration files
Basic Regex Syntax
| Pattern | Matches | Example |
|---|---|---|
| . | Any character | a.c matches "abc", "axc" |
| * | 0 or more | ab* matches "a", "ab", "abb" |
| + | 1 or more | ab+ matches "ab", "abb" |
| ? | 0 or 1 | ab? matches "a", "ab" |
| ^ | Start of string | ^Hello matches "Hello world" |
| $ | End of string | world$ matches "Hello world" |
| \d | Any digit 0-9 | \d+ matches "123" |
| \w | Word character | \w+ matches "hello" |
| \s | Whitespace | \s matches space, tab |
| [abc] | a, b, or c | [aeiou] matches vowels |
| [^abc] | Not a, b, or c | [^0-9] matches non-digits |
Common Regex Patterns
Email address
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}Matches: hello@taptools.dev
URL
https?:\/\/[^\s]+
Matches: https://taptools.dev
Phone number
\+?[1-9]\d{1,14}Matches: +1234567890
Date (YYYY-MM-DD)
\d{4}-\d{2}-\d{2}Matches: 2026-05-01
IP address
\b(?:\d{1,3}\.){3}\d{1,3}\bMatches: 192.168.1.1
Regex Flags
gGlobalFind all matches, not just the firstiInsensitiveCase insensitive matchingmMultiline^ and $ match start/end of each linesDotAllDot matches newlines tooTest regex patterns instantly
Our regex tester shows matches highlighted in real time as you type.
Open Regex Tester →