HandyTools Hub

Regex Reference

Browse 30+ common regex patterns and syntax tokens with examples.

The Regex Reference is a curated cheat sheet of 30+ ready-to-use regular expressions plus a guide to regex syntax tokens. It is built for developers who need a proven pattern without reinventing it, and for learners who want to understand what symbols like ^, +?, and (?= actually mean.

How to Use

  • Browse by category: Patterns are grouped into validation, web, numbers, formatting, and strings.
  • Pick a pattern: Each card shows the regex, a description, and an example string it matches.
  • Copy the pattern: Use it directly in your JavaScript, Python, or other code.
  • Look up syntax: Check the token reference for anchors, quantifiers, groups, and lookaheads.

Features

  • 30+ battle-tested patterns with descriptions and match examples
  • Five categories: validation, web, numbers, formatting, and strings
  • 24 syntax tokens documented with concrete examples
  • Patterns for emails, URLs, IPv4, dates, times, slugs, and more

How Regular Expressions Work

A regular expression is a small program that describes a set of strings. When you run it, a regex engine scans your text and tries to match the pattern character by character. Anchors like ^ and $ pin the match to the start or end of a line, character classes like \d define what one position may contain, and quantifiers like {2,4} say how often it may repeat.

Two ideas trip people up most often. First, quantifiers are greedy: .* swallows as much as it can, so adding a question mark (.*?) makes it lazy and often fixes over-matching. Second, regex engines differ between languages — lookbehind and named groups work in modern JavaScript and Python but not everywhere. Always test a copied pattern where it will actually run.

Use Cases

  • Form validation: Grab proven patterns for emails, phone numbers, URLs, and dates.
  • Data cleaning: Match and extract file extensions, whitespace, or currency amounts.
  • Learning: Study each syntax token with a working example next to it.
  • Code review: Quickly decode an unfamiliar regex left in a codebase.

Frequently Asked Questions

How many regex patterns are included?

The reference includes over 30 commonly used regex patterns across five categories: validation (email, URL, phone, etc.), web (HTML tags, CSS colors, hashes), numbers (integers, decimals, currency), formatting (slugs, camelCase, snake_case), and strings (file extensions, whitespace).

Can I test the patterns directly on this page?

Each pattern card shows a practical example of text that matches the regex. For full interactive regex testing with match groups and flags, visit our Regex Tester tool, which is linked in the related tools section.

What regex syntax tokens are documented?

The reference covers 24 syntax tokens organized by category: anchors, quantifiers, character sets, groups, character escapes, alternation, and lookaheads with examples for each.