←
Developer

Regex Generator

Loading the tool…

Ready when you are.Runs in this browser · nothing is uploaded

Regex library, builder and code snippets

  • Free
  • No sign-up
  • No upload
  • Works offline

Tool facts

Price
Free, no sign-up, no watermark
Are files uploaded?
No. Everything is processed in this browser, on your device.
Offline use
Works without a connection once this page has loaded
Built with
Web Workers
Browser
A recent Chrome, Edge, Firefox or Safari, on computer or phone.

Check it yourself: press F12, open the Network tab, then use the tool. No request carries your data.

About Regex Generator

Regex Generator gives you ready-made regular expressions for everyday validation and search tasks and turns them into code. The library holds 51 patterns, including email addresses, URLs, domains, IPv4 and IPv6, MAC addresses, ISO, US and European dates, 24- and 12-hour times, UUIDs, semantic versions, JWTs, Base64, credit card numbers, IBANs, E.164 and Chinese mobile numbers, and postal codes for the US, UK, Canada, Germany, China, Japan and India. Each pattern comes with a short explanation and examples that it should match and should reject.

Not in the library? The builder assembles a pattern from blocks such as literal text (escaped for you), digits, letters or a custom set, each with a repeat count and an optional capture group, anchored to the whole input, the start, the end or anywhere. Every pattern can be tested live against your own text, line by line, and copied as ready-to-paste code for JavaScript, Python, PHP, Java or Go with the right escaping and flags for each language. Matching runs in your browser in a background worker with a time limit.

Regex Generator runs entirely in your browser. Your data is processed on your device and is never uploaded to Qiyi or anyone else.

How to use Regex Generator

  1. In Library, search or pick a category and click a pattern, or switch to Builder and add blocks such as Text, Digits or Letters with a Repeat count.
  2. Check the pattern and toggle the flags g, i, m, s and u under Regular expression. You can also edit the pattern directly.
  3. Type or paste lines into Test. With Test each line separately on, every line is marked ✓ or ✗ and matches are highlighted.
  4. Pick JavaScript, Python, PHP, Java or Go under Code and click Copy code.

Frequently asked questions

Are these patterns tested?

Yes. Every library pattern is checked against its listed matching and non-matching examples with the JavaScript engine, and the generated Python and Go code is checked with those languages' own regex engines (Go skips patterns that use lookahead or backreferences, which RE2 does not support). Patterns validate format, not meaning: the date patterns do not know that February has 28 or 29 days, and the credit card pattern does not run the Luhn checksum.

Why is my email address rejected?

The email pattern is a practical check for addresses like name@example.com: letters, digits and . _ % + - before the @, and a domain with a top-level part of at least two letters. It deliberately rejects rare forms that the RFC allows, such as quoted local parts or IP-address domains. The only reliable test for an email address is to send a confirmation message.

What changes between JavaScript, Python, PHP, Java and Go?

The escaping and the flag syntax. Python uses a raw string with re.IGNORECASE and similar flags and (?P<name>…) for named groups, PHP wraps the pattern in / delimiters inside a single-quoted string, Java doubles every backslash and uses Pattern flags, and Go uses a raw string with inline flags such as (?i). Go's RE2 engine has no lookahead, lookbehind or backreferences, and Python's re module does not support \p{L}; the tool shows a note when your pattern uses them.

What do ^ and $ do in these patterns?

They anchor the pattern to the start and end of the text, so the whole input must match, which is what you want for validating a form field. Remove them, or choose Anywhere in the builder, to find matches inside longer text. In Python, Java and PHP $ also matches just before a final line break; use \Z in Python or \z in Java and PHP for a strict end.

Is my test text uploaded?

No. The patterns, the builder and the tester all run in your browser. The tester uses a background worker that stops a pattern after one second, so a pattern with catastrophic backtracking cannot freeze the page, and it checks at most 20,000 characters and 2,000 matches.

· Free · Runs in this browser · nothing is uploaded

Drop any file here
Drop it to see which tools can open it