Qaynaq LABS · TOOLS

QAYNAQ LABS · DEV

Regex by use case

Email validation, phone numbers (any country), URLs, credit cards, strong passwords, ISO dates, UUIDs, slugs, hex colors — each pattern at multiple strictness levels with the edge cases that trip naive regex.

"There's a regex for that" is true about 95% of the time, but writing the regex from scratch is the slow 95%. Most dev questions about pattern matching aren't research questions — they're cookbook questions: "give me the pattern that handles X, with the edge cases I shouldn't have to discover myself."

Qaynaq Labs' regex cookbook is that reference. Every entry includes patterns at multiple strictness levels (because the right answer depends on whether you're validating signups or filtering server logs), match/doesn't-match examples, idiomatic code in four languages (JavaScript, Python, Go, Ruby), and the edge cases that trip naive patterns: internationalized domains, multi-byte characters, plus-addressing in emails, country-specific phone formats. Pick the strictness that fits your use case and paste.

Frequently asked

Why multiple patterns per use case?

Strictness is a trade-off. Strict patterns reject valid edge cases (legitimate emails like a+b@c.io); loose patterns admit false positives. We list 2-3 patterns per use case so you can pick the right trade-off for your context.

Are these tested?

Each pattern ships with concrete matches and non-matches drawn from real-world strings. Run them in your language of choice to confirm.

What about catastrophic backtracking?

The pitfalls block on each page calls out catastrophic-backtracking risk where it applies. We avoid nested quantifiers in the suggested patterns.

Can I use these for security validation?

Regex is fine for format validation (does this look like an email?) but a poor substitute for behavioral validation (does this email actually receive mail?). The pitfalls block notes when format validation is insufficient.