Regular Expression Cheat Sheet
Detailed regular expression patterns guide
Regular Expression Cheat Sheet
Comprehensive reference guide for Regular Expressions with common patterns. Click the copy button to copy any pattern.
99
Total Commands
99
Filtered Results
Character Classes
Command | Copy | Description |
---|---|---|
. | Any character except newline | |
\d | Any digit [0-9] | |
\D | Any non-digit | |
\w | Word character [a-zA-Z0-9_] | |
\W | Non-word character | |
\s | Whitespace character | |
\S | Non-whitespace character | |
[abc] | Any of a, b, or c | |
[^abc] | Not a, b, or c | |
[a-z] | Character between a and z | |
[A-Z] | Character between A and Z | |
[0-9] | Any digit | |
[a-zA-Z] | Any letter |
Quantifiers
Command | Copy | Description |
---|---|---|
* | Zero or more | |
+ | One or more | |
? | Zero or one | |
{n} | Exactly n times | |
{n,} | n or more times | |
{n,m} | Between n and m times | |
*? | Zero or more (lazy) | |
+? | One or more (lazy) | |
?? | Zero or one (lazy) | |
{n,}? | n or more (lazy) | |
{n,m}? | n to m (lazy) |
Anchors
Command | Copy | Description |
---|---|---|
^ | Start of string/line | |
$ | End of string/line | |
\b | Word boundary | |
\B | Not word boundary | |
\A | Start of string | |
\Z | End of string | |
\z | Absolute end of string |
Groups and Capturing
Command | Copy | Description |
---|---|---|
(abc) | Capturing group | |
(?:abc) | Non-capturing group | |
(?<name>abc) | Named capturing group | |
\1 | Backreference to group 1 | |
\k<name> | Named backreference | |
(?=abc) | Positive lookahead | |
(?!abc) | Negative lookahead | |
(?<=abc) | Positive lookbehind | |
(?<!abc) | Negative lookbehind |
Alternation
Command | Copy | Description |
---|---|---|
a|b | a or b | |
(cat|dog) | cat or dog |
Special Characters
Command | Copy | Description |
---|---|---|
\ | Escape special character | |
\n | Newline | |
\r | Carriage return | |
\t | Tab | |
\v | Vertical tab | |
\f | Form feed | |
\0 | Null character | |
\xhh | Hex character | |
\uhhhh | Unicode character |
Flags/Modifiers
Command | Copy | Description |
---|---|---|
i | Case-insensitive | |
g | Global match | |
m | Multiline | |
s | Dot matches newline | |
u | Unicode | |
x | Extended (ignore whitespace) | |
y | Sticky |
Email Validation
Command | Copy | Description |
---|---|---|
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ | Basic email validation | |
^[\w.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$ | Email with subdomains |
URL Validation
Command | Copy | Description |
---|---|---|
^https?://[^\s]+$ | Basic URL | |
^(https?|ftp)://[^\s/$.?#].[^\s]*$ | URL with protocols | |
^https?://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?$ | Complete URL validation |
Phone Numbers
Command | Copy | Description |
---|---|---|
^\d{3}-\d{3}-\d{4}$ | US phone (xxx-xxx-xxxx) | |
^\(?\d{3}\)?[- ]?\d{3}[- ]?\d{4}$ | Flexible US phone | |
^\+?\d{1,3}?[- ]?\(?\d{1,4}\)?[- ]?\d{1,4}[- ]?\d{1,9}$ | International phone |
Dates
Command | Copy | Description |
---|---|---|
^\d{4}-\d{2}-\d{2}$ | Date (YYYY-MM-DD) | |
^\d{2}/\d{2}/\d{4}$ | Date (MM/DD/YYYY) | |
^(0[1-9]|1[0-2])/(0[1-9]|[12]\d|3[01])/\d{4}$ | Validated MM/DD/YYYY |
Time
Command | Copy | Description |
---|---|---|
^([01]?[0-9]|2[0-3]):[0-5][0-9]$ | Time (HH:MM 24-hour) | |
^(0?[1-9]|1[0-2]):[0-5][0-9] (AM|PM)$ | Time (12-hour with AM/PM) |
IP Addresses
Command | Copy | Description |
---|---|---|
^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$ | IPv4 address | |
^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$ | Valid IPv4 |
Credit Cards
Command | Copy | Description |
---|---|---|
^4[0-9]{12}(?:[0-9]{3})?$ | Visa card | |
^5[1-5][0-9]{14}$ | MasterCard | |
^3[47][0-9]{13}$ | American Express | |
^3(?:0[0-5]|[68][0-9])[0-9]{11}$ | Diners Club |
Passwords
Command | Copy | Description |
---|---|---|
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$ | Strong password (8+ chars, upper, lower, digit) | |
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&]).{8,}$ | Strong password with special char |
Usernames
Command | Copy | Description |
---|---|---|
^[a-zA-Z0-9_]{3,16}$ | Username (3-16 alphanumeric) | |
^[a-zA-Z][a-zA-Z0-9_]{2,15}$ | Username (starts with letter) |
Colors
Command | Copy | Description |
---|---|---|
^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$ | Hex color code | |
^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)$ | RGB color |
Numbers
Command | Copy | Description |
---|---|---|
^-?\d+$ | Integer | |
^-?\d*\.?\d+$ | Decimal number | |
^-?\d+(\.\d{1,2})?$ | Decimal with 1-2 places | |
^\d{1,3}(,\d{3})*$ | Number with commas |
HTML/XML
Command | Copy | Description |
---|---|---|
<([a-z]+)([^>]*)>(.*?)</\1> | HTML tag with content | |
<([a-z]+)([^>]*)/> | Self-closing tag | |
<!--.*?--> | HTML comment |
Files
Command | Copy | Description |
---|---|---|
\.txt$ | Text file | |
\.(jpg|jpeg|png|gif)$ | Image file | |
\.(pdf|doc|docx|txt)$ | Document file |
Social Media
Command | Copy | Description |
---|---|---|
^@[a-zA-Z0-9_]{1,15}$ | Twitter handle | |
^#[a-zA-Z0-9_]+$ | Hashtag |
Common Patterns
Command | Copy | Description |
---|---|---|
^[a-zA-Z\s]+$ | Letters and spaces only | |
^[a-zA-Z0-9]+$ | Alphanumeric only | |
^\s*$ | Empty or whitespace | |
^(?!\s*$).+ | Not empty |
All operations are performed locally in your browser. No data is sent to any server.
About Regular Expression Cheat Sheet
This section will contain detailed, SEO-friendly content about the Regular Expression Cheat Sheet.
In the future, this content will be managed through a headless CMS, allowing you to:
- Add detailed explanations about how to use this tool
- Include examples and use cases
- Provide tips and best practices
- Add FAQs and troubleshooting guides
- Update content without touching the code
How to Use
Step-by-step instructions for using the Regular Expression Cheat Sheet will appear here. This content will be fully customizable through the admin panel.
Features
Key features and benefits of this tool will be listed here. All content is editable via the CMS.