DevKits
29 patterns

Regex Cookbook

Battle-tested regular expressions for the tasks developers do every week — validation, extraction, cleanup — with ready-to-paste snippets in JavaScript, Python, Go, and Java.

Every entry explains the pattern piece by piece, shows real matches and non-matches, and calls out the common pitfall that catches most people — the reason your pattern “works but misses one case.” When regex is not the right tool at all (URL parsing, phone numbers, HTML), we say so and point at the language-native alternative.

Try any pattern live in our Regex Tester.

Validation

Verify that input matches an expected format — email, URL, IP, UUID, password strength.

Extraction

Pull specific pieces of information out of a larger text: hashtags, mentions, query params.

Text

Normalize and clean text: collapse whitespace, remove empty lines, catch duplicate words.

Dates & Times

Match ISO 8601 dates, timestamps, and 24-hour times.

Numbers

Integers, floats, scientific notation, and hexadecimal literals.

Web

Domain names and other web-specific tokens.

Code

Match programming identifiers (camelCase, PascalCase, snake_case) and comments.