Regular Expression Cheat Sheet
A quick reference of commonly used regular expressions covering 18 everyday cases such as email, phone number, URL, IP, ID card number and date, each with an explanation, plus keyword search and one-click copy.
FreeOnline Tool
Loading…
How to Use
- The page lists all the built-in regular expressions with their explanations by default.
- Type a keyword in the search box, such as email, phone, URL or IP, or part of an expression, to filter the list as you type.
- Click any regular expression to copy it to the clipboard; a short "Copied" confirmation appears.
Features
- 18 built-in patterns for everyday cases: email address, mainland China mobile number, URL, IPv4 address, 18-digit Chinese ID card number, date format, Chinese characters, integers and decimals, hex color, username, strong password, HTML tag, Windows file path, MAC address, trimming leading and trailing whitespace, QQ number and mainland China license plate.
- Every pattern comes with a description of what it is for, so its intended use is clear.
- Live search filtering by the name of the use case or by keywords in the description.
- Click a pattern to copy it to the clipboard and paste it straight into your code.
Use Cases
Looking up form validation rules
Copy a ready-made email or phone number pattern while building form validation instead of writing one from scratch.
Reference for data extraction
When pulling URLs, IP addresses or dates out of text, start from a pattern that already works.
Checking regexes during code review
Compare the expressions in someone else's code against the standard forms in the cheat sheet.
Learning common regex idioms
Beginners can browse patterns across many scenarios with explanations and build up a repertoire of practical idioms.
FAQ
Can I drop these patterns straight into production code?
They are general-purpose expressions for common cases and work well as a reference or a starting point. If your business has particular validation requirements, such as the ID card checksum algorithm or newly issued mobile number prefixes, adapt them to your own situation before relying on them.
Does the ID card pattern only check the format?
Yes. The built-in Chinese ID card pattern only checks the structure of 18 digits ending in a check character (a digit or X/x). It does not validate the birth date, verify that the region code is real, or compute whether the final check digit is correct.
Does the IPv4 pattern check the numeric range?
No. The built-in IPv4 pattern only checks the shape of four dot-separated groups of digits; it does not verify that each group is within 0-255. For strict validation use a more elaborate pattern or add a numeric check in code.
What can I search by?
You can search by the name of the pattern, such as email address, by keywords in its description, such as URL, or by a fragment of the expression itself.