Regex Generator

Runs in browser Utilities

Compose a regex without memorising syntax: pick a proven pattern, set anchors, quantifiers, character classes and flags, and validate against your own sample strings before copying.

Privacy: This tool runs entirely in your browser. Your input never leaves your device.
Loading tool…

How to use Regex Generator

  1. Pick a pattern from the library, or type a custom pattern or a literal string.
  2. Add flags (for example i) and choose whether to anchor the whole string.
  3. Paste sample values one per line to confirm the pattern behaves as expected.
  4. Copy the regex or the code snippet for your language.

Regex Generator features

  • Library of 40+ patterns with self-tests: email, URL, IPv4/IPv6, UUID, semver, ISO dates, IBAN, credit cards, Saudi/Jordan/UAE/India phone numbers, national IDs and more
  • Literal-text mode that escapes special characters automatically
  • Whole-string anchoring and extra flags in one click
  • Sample strings tested line by line with a match / no-match verdict
  • Ready-to-paste snippets for JavaScript, TypeScript, Python, Java, C# and Go
  • Browse the whole library as a downloadable table

Regex Generator example

Validate Saudi mobile numbers

Input:

Library: Saudi mobile (+966 5X)
Samples:
+966501234567
0551234567
+962791234567

Output:

/^(?:\+966|00966|0)?5[0-9]{8}$/
+966501234567 → ✓ match
0551234567 → ✓ match
+962791234567 → ✗ no match

Frequently asked questions about Regex Generator

What patterns are in the library?

More than 40 tested patterns: email, URL, domain, slug, IPv4/IPv6, MAC, port, UUID, ULID, semver, hex colour, JWT, ISO dates and times, credit cards, IBAN (generic and Saudi), Saudi and Jordanian mobile numbers, Saudi national ID, UAE and Indian mobiles, E.164, Arabic and Devanagari text, passwords, base64, hashes and more.

Are the library patterns validated?

Every pattern ships with strings it must match and strings it must reject, and the unit-test suite verifies all of them on every build.

Can I match a literal string that contains special characters?

Yes — type it in the "Literal text" field and the generator escapes characters such as . * ? ( ) [ ] so they match exactly.

Which programming languages are supported for the snippet?

JavaScript, TypeScript, Python, Java, C# and Go. Flags are translated to the equivalent options (for example re.IGNORECASE or RegexOptions.IgnoreCase).

Should I rely on a regex alone to validate an IBAN or credit card?

No. The patterns check the format only; always add the checksum (MOD-97 for IBAN, Luhn for card numbers) in your application logic.

Technical notes

Every library entry carries positive and negative examples. A unit test compiles each pattern and asserts all examples, so a broken pattern fails the build rather than reaching users. Patterns deliberately validate format only; checksums such as IBAN MOD-97 and Luhn belong in application code.