Regex Generator
Developer ToolsGenerate ready-to-use regex patterns for email, phone, URL, dates, Indian IDs, and more. Paste a test string to check for a match — free, browser-based.
What is a Regex?
A Regex Generator provides ready-to-use regular expression patterns for the most common validation and parsing tasks in web development — covering international formats like email addresses and URLs alongside India-specific identifiers like PAN numbers, GST numbers, Aadhaar, and Indian mobile numbers.
Regular expressions are one of the most powerful tools in a developer's toolkit, but writing them correctly from scratch is time-consuming and error-prone. A single misplaced bracket or a forgotten escape character can produce a pattern that silently passes invalid input or rejects valid input. The generator provides verified patterns for 20 common use cases, formatted as JavaScript-compatible regex literals with the surrounding / delimiters and any chosen flags already applied.
The tool also serves as a quick reference: select a pattern type to see a valid example string alongside the regex, which is useful both for understanding what the pattern matches and for generating test data that will pass the validation.
For Indian developers, the collection covers the five IDs most commonly validated in web applications: PAN (for income tax and financial KYC flows), GST number (for B2B invoicing), Aadhaar (basic 12-digit format check), Indian mobile number (10 digits starting with 6–9), and Indian pincode (6-digit format). The PAN Validator and GST Validator apply these same patterns with detailed segment-by-segment explanations of what each part means.
Use the UUID Generator to generate IDs for test records you create while verifying these patterns in your application. For building test data tables using regex-validated values, the Markdown Table Generator lets you document your validation rules in a readable format.
How to use this Regex calculator
- Select a pattern type from the dropdown — 20 common patterns from email and URL to Indian IDs and colour codes.
- Choose flags if needed — leave as None for single-value validation; select Global for extracting multiple matches from a longer string; select Case-insensitive for patterns where capitalisation should not matter.
- Click Generate — the pattern and a valid example appear immediately.
- Optionally enter a test string in the Test String field to verify the pattern against a specific value. The test result updates automatically.
- Copy the pattern from the Regex Pattern output field and paste it into your code.
- Adapt for your language if needed — strip the
/delimiters for Python (re.compile(r'pattern')), Java (Pattern.compile("pattern")), or SQL (REGEXP 'pattern').
Formula & Methodology
All 20 patterns are anchored with^(start of string) and$(end of string), making them suitable for full-string validation rather than substring matching. The anchors can be removed if you need to find the pattern within a longer text. Selected pattern details: | Pattern Type | Key rules | |---|---| | Email |[^\s@]+@[^\s@]+\.[^\s@]+— no spaces or@before the@, a dot and non-empty TLD after | | Indian Mobile |[6-9]\d{9}— first digit 6–9, exactly 9 more digits | | URL |https?://prefix, no whitespace in the rest | | IPv4 | Each octet 0–255 using25[0-5]\|2[0-4]\d\|[01]?\d\d?| | PAN |[A-Z]{5}[0-9]{4}[A-Z]— 5 uppercase letters, 4 digits, 1 uppercase letter | | GST |[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z][1-9A-Z]Z[0-9A-Z]— 2-digit state, embedded PAN, entity code | | Aadhaar |[1-9][0-9]{11}— 12 digits, first digit non-zero | | Hex colour |#([A-Fa-f0-9]{6}\|[A-Fa-f0-9]{3})— 3 or 6 hex digits after#| | Slug |[a-z0-9]+(-[a-z0-9]+)*— lowercase alphanumeric segments joined by hyphens | The test uses JavaScript'sRegExpconstructor with the raw pattern string and the selected flags, run synchronously in the browser.