Regex Cheat Sheet
Regular expressions syntax reference guide
Regex Cheat Sheet
Quick reference guide for Regular Expressions. Click the copy button to copy any pattern.
81
Total Commands
81
Filtered Results
Character Classes
Command | Copy | Description |
---|---|---|
. | Any character except newline | |
\d | Any digit (0-9) | |
\D | Any non-digit | |
\w | Any word character (a-z, A-Z, 0-9, _) | |
\W | Any non-word character | |
\s | Any whitespace character | |
\S | Any non-whitespace character | |
[abc] | Any character in set (a, b, or c) | |
[^abc] | Any character not in set | |
[a-z] | Any lowercase letter | |
[A-Z] | Any uppercase letter | |
[0-9] | Any digit |
Quantifiers
Command | Copy | Description |
---|---|---|
* | Zero or more times | |
+ | One or more times | |
? | Zero or one time (optional) | |
{n} | Exactly n times | |
{n,} | At least n times | |
{n,m} | Between n and m times | |
*? | Zero or more (lazy/non-greedy) | |
+? | One or more (lazy/non-greedy) | |
?? | Zero or one (lazy/non-greedy) |
Anchors
Command | Copy | Description |
---|---|---|
^ | Start of string or line | |
$ | End of string or line | |
\b | Word boundary | |
\B | Non-word boundary | |
\A | Start of string (not line) | |
\Z | End of string (not line) |
Groups and Capturing
Command | Copy | Description |
---|---|---|
(abc) | Capture group | |
(?:abc) | Non-capturing group | |
(?<name>abc) | Named capture group | |
\1 | Backreference to group 1 | |
(?=abc) | Positive lookahead | |
(?!abc) | Negative lookahead | |
(?<=abc) | Positive lookbehind | |
(?<!abc) | Negative lookbehind |
Alternation
Command | Copy | Description |
---|---|---|
a|b | Match a or b | |
(cat|dog) | Match cat or dog |
Special Characters
Command | Copy | Description |
---|---|---|
\ | Escape special character | |
\n | Newline | |
\r | Carriage return | |
\t | Tab | |
\0 | Null character | |
\x{hh} | Character with hex code hh |
Flags/Modifiers
Command | Copy | Description |
---|---|---|
i | Case-insensitive matching | |
g | Global matching (find all) | |
m | Multiline mode | |
s | Dot matches newline | |
u | Unicode mode | |
x | Ignore whitespace and comments |
Common Patterns
Command | Copy | Description |
---|---|---|
^[a-zA-Z0-9]+$ | Alphanumeric string | |
^[a-zA-Z]+$ | Letters only | |
^[0-9]+$ | Numbers only | |
^\d{3}-\d{3}-\d{4}$ | Phone number (xxx-xxx-xxxx) | |
^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ | Email address | |
^https?://[^\s]+$ | URL | |
^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$ | Hex color code | |
^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$ | IP address | |
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$ | Strong password | |
^[A-Z][a-z]+ [A-Z][a-z]+$ | Full name (First Last) | |
^\d{5}(-\d{4})?$ | US ZIP code | |
^[0-9]{4}-[0-9]{2}-[0-9]{2}$ | Date (YYYY-MM-DD) |
Username Patterns
Command | Copy | Description |
---|---|---|
^[a-zA-Z0-9_]{3,16}$ | Username (3-16 chars) | |
^@[a-zA-Z0-9_]{1,15}$ | Twitter handle |
File Extensions
Command | Copy | Description |
---|---|---|
\.txt$ | Match .txt files | |
\.(jpg|jpeg|png|gif)$ | Match image files | |
\.(pdf|doc|docx)$ | Match document files |
HTML/XML Patterns
Command | Copy | Description |
---|---|---|
<([a-z]+)([^>]*)>.*?</\1> | Match HTML tag | |
<!--.*?--> | Match HTML comment |
Number Patterns
Command | Copy | Description |
---|---|---|
^-?\d+$ | Integer (positive or negative) | |
^-?\d*\.?\d+$ | Decimal number | |
^\d{1,3}(,\d{3})*$ | Number with commas | |
^\$?\d+(\.\d{2})?$ | Currency amount |
Credit Card Patterns
Command | Copy | Description |
---|---|---|
^4[0-9]{12}(?:[0-9]{3})?$ | Visa card number | |
^5[1-5][0-9]{14}$ | MasterCard number | |
^3[47][0-9]{13}$ | American Express number |
Social Security
Command | Copy | Description |
---|---|---|
^\d{3}-\d{2}-\d{4}$ | US Social Security Number |
Time Patterns
Command | Copy | Description |
---|---|---|
^([0-1]?[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) |
Whitespace
Command | Copy | Description |
---|---|---|
^\s*$ | Empty or whitespace only | |
\s+ | One or more whitespace | |
^\S+$ | No whitespace |
All operations are performed locally in your browser. No data is sent to any server.
About Regex Cheat Sheet
This section will contain detailed, SEO-friendly content about the Regex 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 Regex 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.