Skip to main content
Preparing workspace

Regex Library

Copy tested regular expressions for email, phone numbers, URLs, dates, password rules, card number formats and Indian documents like PAN, Aadhaar and GSTIN, and test them live.

About this tool

Regex Library

Copy tested regular expressions for email, phone numbers, URLs, dates, password rules, card number formats and Indian documents like PAN, Aadhaar and GSTIN, and test them live.

Pick a pattern type, copy the regex and try it against your own sample text. This page brings together 7 separate regex library pages (Card formats, Dates, Email, Indian documents, Passwords, Phone numbers, URLs) so you can compare them without hunting for the right one.

How to use Regex Library

  1. 1

    Open Regex Library on AltFTool — it loads instantly in your browser.

  2. 2

    Choose your pattern type at the top: Card formats, Dates, Email, Indian documents and 3 more. On a phone it is a drop-down list.

  3. 3

    Fill in the regex library for that pattern type; each of the 7 options keeps its own rules, data and defaults.

  4. 4

    Read the result, then switch pattern type to compare. The page link keeps your pattern type (?v=card-formats), so you can bookmark or share it.

Why use Regex Library

  • All 7 in one place

    Card formats, Dates, Email and the rest sit behind one picker, so switching pattern type takes a tap instead of a new search.

  • Built for each option

    Every pattern type keeps its own rules, numbers and defaults rather than one generic template.

  • Shareable view

    The link remembers the pattern type you picked, so a bookmark or a shared link opens straight on it.

Common use cases

  • A checkout form developer showing the right network badge and input grouping as the user types a test card number
  • An API developer validating that request payload fields are RFC 3339 timestamps like 2026-07-26T14:30:00Z before parsing
  • A frontend developer matching server-side validation to the exact regex browsers use for input type=email
  • A fintech onboarding flow validating PAN and IFSC format client-side before calling paid verification APIs

Frequently asked questions

Which pattern type options does this tool cover?

7: Card formats, Dates, Email, Indian documents, Passwords, Phone numbers, URLs. Pick one at the top of the tool; the page link updates (for example ?v=card-formats) so you can bookmark or share that exact view.

What is the regex for a Visa card number?

^4[0-9]{12}(?:[0-9]{3})?(?:[0-9]{3})?$ — a leading 4 followed by 12 more digits, optionally extended to 16 or 19 digits. It identifies the format only; it does not run a Luhn check or confirm the card exists, so use it for UI hints, not validation of payment ability.

What is the regex for an ISO 8601 date?

^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$ matches YYYY-MM-DD with the month held to 01–12 and the day to 01–31. It cannot know that April has 30 days or apply leap-year rules — 2026-02-31 still passes — so parse the match with a date library to confirm the day exists.

What is the best regex for email validation?

For most web forms, the WHATWG HTML5 pattern is the best default because it is the exact regex browsers apply to input type=email, so client and server agree. Stricter is not automatically better: the full RFC 5322 grammar accepts addresses like "john doe"@example.com that many mail systems reject, and the only real proof an address works is a confirmation email.

What is the regex for PAN card validation?

The common pattern is ^[A-Z]{5}[0-9]{4}[A-Z]$, but the stricter ^[A-Z]{3}[PCHFATBLJG][A-Z][0-9]{4}[A-Z]$ also enforces that the 4th character is a valid holder-status letter — P for individuals, C for companies, H for HUF, F for firms and so on. Neither can check the final character, which is a check letter, nor whether the PAN is actually issued.

What is the regex for a password with uppercase, lowercase, number and special character?

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,}$ — four lookaheads each scan the string for one required class, then .{8,} enforces the length. Using [^A-Za-z0-9] for the special character accepts any symbol; patterns that enumerate symbols like [@$!%*?&] reject users whose symbol is not on the list.

What is the regex for E.164 phone number format?

^\+[1-9]\d{1,14}$ — a plus sign followed by 2 to 15 digits whose first digit is 1–9. E.164 is the ITU-T standard for international numbers, caps them at 15 digits, and is the format SMS and voice APIs such as Twilio require, so it is the right shape to store in your database.

What is a good regex to validate a URL?

For web links, use ^https?:\/\/(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,63}(?::\d{1,5})?(?:\/[^\s?#]*)?(?:\?[^\s#]*)?(?:#\S*)?$ — it requires http or https, a dotted domain with an alphabetic TLD, and allows an optional port, path, query and fragment. In JavaScript, new URL(value) inside a try/catch is more correct than any regex because it implements the full WHATWG URL Standard.