India · Dubai · Delivering worldwide+91 86603 71224info@pyalm.com
Pyalm Labs logo
Free Tools

Regex Cheat Sheet with Real Examples (Emails, Phones, Dates, UAE TRN)

A practical regular expression cheat sheet — the syntax you actually use, plus tested patterns for emails, UAE and Indian phone numbers, dates and tax numbers.

Editorial disclosure: Pyalm publishes and maintains the products and free tools discussed on this site. Regulatory statements are linked to primary sources where applicable. No independent professional review is claimed unless a reviewer is explicitly named.

Regular expressions look cryptic, but most real-world patterns use a small set of building blocks. This cheat sheet covers that core syntax, then shows tested patterns you can paste straight into the free Regex Tester and adapt.

The building blocks

Pattern Matches
. Any character except a newline
\d \w \s A digit · a word character (letter, digit, _) · whitespace
\D \W \S The opposite of each
[abc] One of a, b or c
[^abc] Any character except a, b or c
[a-z0-9] A range
^ $ Start · end of the string (or line, with the m flag)
\b A word boundary

Quantifiers

Pattern Means
a* Zero or more
a+ One or more
a? Optional (zero or one)
a{3} Exactly 3
a{2,5} Between 2 and 5
a+? Lazy — as few as possible

Quantifiers are greedy by default: <.+> on <b>bold</b> matches the whole string. Add ? to make it lazy and match just <b>.

Groups and alternation

  • (abc) — capture group, available as $1 in replacements
  • (?<year>\d{4}) — named group, available as $<year>
  • (?:abc) — group without capturing
  • cat|dog — either side
  • (?=x) / (?!x) — lookahead: followed / not followed by x
  • (?<=x) / (?<!x) — lookbehind: preceded / not preceded by x

Flags

g find all matches · i ignore case · m ^ and $ match per line · s dot matches newlines · u full Unicode.

Ready-made patterns

Email (practical, not RFC-perfect)

[\w.+-]+@[\w-]+\.[\w.-]+

Good for finding emails in text. Never rely on regex alone to validate sign-up emails — send a confirmation link.

UAE mobile number

(?:\+971|00971|0)?5[024568]\d{7}

Matches +971501234567, 0559876543 and 00971521112233.

Indian mobile number

(?:\+91[\s-]?)?[6-9]\d{9}

Date in YYYY-MM-DD with named groups

(?<year>\d{4})-(?<month>0[1-9]|1[0-2])-(?<day>0[1-9]|[12]\d|3[01])

It checks the shape, not the calendar — 2026-02-31 still matches. Validate real dates in code.

UAE TRN (15 digits starting with 100)

\b100\d{12}\b

For a full format check use the UAE TRN Validator.

Indian GSTIN

\b\d{2}[A-Z]{5}\d{4}[A-Z][1-9A-Z]Z[0-9A-Z]\b

Replacing with groups

Reformat dates from YYYY-MM-DD to DD/MM/YYYY with the date pattern above and the replacement $<day>/$<month>/$<year>. The Regex Tester previews the result before you put it in code.

Avoid catastrophic backtracking

Nested quantifiers like (a+)+ or (\w+\s?)$ can take exponential time on inputs that almost* match — enough to freeze a browser or take down a server. Keep patterns specific, avoid quantifying a group that already contains a quantifier, and anchor patterns where you can.

Beyond regex

Regex is perfect for well-defined formats. For messy real-world documents — invoices, receipts, contracts — where layouts vary, AI document extraction is far more robust than ever-growing patterns. Pyalm builds AI document-processing pipelines that read documents and push structured data into your systems.

Regex Tester | JSON Formatter | URL Encoder | TRN Validator | All free tools

Keep reading

More from Pyalm

Nov 27, 2026

Prescription Abbreviations: What OD, BD, TDS, SOS and 1-0-1 Mean

A plain-English list of prescription abbreviations: dose timing (OD, BD, TDS, QID), when to take (AC, PC, HS, SOS), routes, forms, the 1-0-1 dose grid and abbreviations to avoid.

Nov 27, 2026

Handwritten vs Typed Prescriptions: Which Is Safer?

Why legibility matters in prescribing, what changes when clinics move from handwritten to typed or electronic prescriptions, and how to keep a handwritten signature.

Nov 27, 2026

How to Write a Prescription in India: Format and Rules

A practical prescription format for doctors in India: required details, generic names in capitals, the 1-0-1 grid, Schedule H and controlled drugs, and keeping records.

Nov 27, 2026

Prescription Pad Design: Letterhead Template for Clinics

What a professional prescription letterhead should include, paper size, layout, bilingual Arabic and English pads, QR codes for verification and printing tips.

Nov 27, 2026

Prescription Errors: 10 Common Mistakes and How Clinics Prevent Them

The ten prescription mistakes that cause dispensing errors, from illegible names and decimal points to missing durations, and simple fixes for clinics.

Oct 16, 2026

How to Format and Validate JSON (and Fix the 6 Most Common Errors)

Why JSON breaks, how to read a validator's error message, and a quick routine for pretty-printing, minifying and fixing JSON from APIs, logs and config files.

Try the free Regex Tester

Pyalm builds custom software, APIs and integrations for businesses in India and the UAE. We made these developer tools for our own team — use them free, and talk to us when you need something built.

Open Regex Tester See custom software All free tools