How to use the Regex Cheat Sheet
- 1. Search or filterType a word like boundary or lookahead, or pick a category.
- 2. Pick a ready patternChoose a format such as Indian mobile number.
- 3. Test itType your own text to see if it matches, or download the sheet.
What the sheet covers
The 48 entries are grouped into characters (\d, \w, \s, .), sets ([a-z], [^0-9]), anchors (^, $, \b), quantifiers (*, +, ?, {2,4} and lazy versions), groups and back-references, lookahead and lookbehind, the seven JavaScript flags (g, i, m, s, u, y, d) and the JavaScript methods that use regex: match, matchAll, test, replace, split and exec.
Each token comes with a short example, such as colou?r matching both color and colour, or \d+(?=%) finding 50 in "50%".
Ready-made patterns, tested
The 14 patterns each come with one example that matches and one that doesn't, and all of them are checked against those examples:
- Indian mobile:
^[6-9]\d{9}$accepts 9876543210 and rejects 1234567890, because Indian mobile numbers start with 6–9. - PIN code:
^[1-9]\d{5}$, six digits with no leading zero. - PAN:
^[A-Z]{5}\d{4}[A-Z]$, like ABCDE1234F. - IFSC: four letters, a 0, then six letters or digits, like SBIN0001234.
- Plus GSTIN, email, dates, 24-hour times, strong passwords, URLs, hex colours, IPv4 addresses and usernames.
These check the format only: a PAN-shaped string might not be a real PAN. Write and debug your own patterns with the Regex Tester.
Frequently asked questions
Is regex the same in every language?
The basics are shared, but details differ. Lookbehind, named groups and flags vary between JavaScript, Python, Java and others. This sheet follows JavaScript.
Should I validate email with regex?
A simple pattern catches typos. The only real check is sending a confirmation email.
What is a lazy quantifier?
Adding ? after *, + or {} makes it match as little as possible, so <.+?> matches one tag instead of everything up to the last >.
Is the regex cheat sheet free?
Yes, it is free. Testing a pattern or downloading the sheet asks for your name and WhatsApp number once. After that, the regex cheat sheet and every other Uncodemy tool open with no form.