Tinkr
All tools
Developer·Live

AI Regex Generator

Describe what you want to match in plain English. Tinkr returns a regex, an explanation, a token-by-token breakdown, and runnable test cases. Optionally provide examples to tighten the result.

Common regex patterns

Curated reference. No request needed.

These are the patterns developers reach for most often. JavaScript flavor. Each one is tested and works as shown.

Email address

Practical email validation — covers the formats developers actually receive.

/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/
hi@tinkrtool.comuser.name+tag@example.co.uk

URL (http or https)

Matches HTTP and HTTPS URLs with optional paths and query strings.

/https?:\/\/[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=]*/g
https://tinkrtool.com/regexhttp://example.com/path?q=1

Phone number (international)

E.164 international format. Optional leading +, then 2–15 digits.

/\+?[1-9]\d{1,14}/
+91987654321014155552671

Indian phone number (+91)

Indian mobile number, optional +91 prefix, must start 6–9.

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

IPv4 address

Strict IPv4 — each octet is 0–255 (no out-of-range numbers).

/(?:25[0-5]|2[0-4]\d|[01]?\d\d?)(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d\d?)){3}/
192.168.1.1255.255.255.0

Hex color code

3-digit or 6-digit hex color, with leading #.

/#(?:[0-9a-fA-F]{3}){1,2}\b/g
#fff#ff5733

ISO 8601 date (YYYY-MM-DD)

ISO 8601 calendar date. Validates month (01–12) and day (01–31).

/\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])/
2026-05-081999-12-31

UUID v4

Standard UUID v4 — version digit fixed at 4, variant digit 8/9/a/b.

/[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i
550e8400-e29b-41d4-a716-446655440000

US ZIP code

5-digit ZIP, optionally followed by a 4-digit ZIP+4 extension.

/\d{5}(?:-\d{4})?/
9410394103-1234

Strong password

Lookahead-based: requires lowercase, uppercase, digit, symbol, and 8+ chars.

/(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z\d]).{8,}/
Pa$$w0rd!Tinkr_2026

Slug (URL-safe)

Lowercase alphanumerics joined by single hyphens. No leading/trailing hyphen.

/[a-z0-9]+(?:-[a-z0-9]+)*/
my-blog-posttinkr-v2

Credit card (basic)

13–19 digit numbers with optional spaces or dashes. Format-only — does not Luhn-check.

/(?:\d[ -]?){13,19}/
4242 4242 4242 42425555-5555-5555-4444

Frequently asked questions

How does the AI regex generator work?
It sends your plain-English description to Google's Gemini model with a strict system prompt that requires a JavaScript-compatible regex, a token-by-token explanation, and 5–8 runnable test cases. Each test case is then executed in your browser against the generated pattern, so you see real pass/fail results — not just the model's claims.
Is the regex JavaScript-compatible?
Yes. The output is ECMAScript-compliant and works in browser JavaScript, Node.js, TypeScript, and any JS-flavor engine. It avoids PCRE-only features like \K, possessive quantifiers, and atomic groups, so the patterns transfer cleanly to most other regex engines too.
Can I use these patterns in Python or Java?
In most cases, yes. Common features (character classes, quantifiers, anchors, lookarounds) work the same in Python's re module and Java's java.util.regex. Edge cases: Python's named groups use (?P<name>...) instead of (?<name>...); Java requires Pattern.compile() and double-escaping in string literals.
Do I need to install anything?
No. The tool runs entirely in your browser. There's no extension, CLI, or IDE plugin. You can use it alongside VS Code, IntelliJ, Sublime, or any editor — paste the result back into your code.
Is it free? Are there usage limits?
Yes, free. Each IP address gets 20 generations per 24 hours. There's no signup, no tracking, and no credit card required. A paid API tier for higher-volume use is on the roadmap.
Why use a regex generator instead of writing it manually?
Because edge cases bite. It's easy to forget to anchor with ^/$, escape a literal dot, or handle empty input. The generator surfaces those edge cases as concrete test cases, so you verify the pattern handles them before shipping it to production.
Can I provide my own examples?
Yes. The optional 'Add examples' section accepts strings that should match and strings that should NOT match (one per line). The model uses these as hard constraints — every positive example must match, and no negative example may match.
What happens if my generated regex doesn't work for an input?
Use the live tester at the bottom of the result panel. Paste any text into it, and matches are highlighted in real time as you type. If something you expected to match doesn't, refine your prompt or add it to the 'Should match' examples and regenerate.

Related tools