Toolkit Hub

Common Regex Patterns

A searchable library of ready-to-use regular expressions.

Common Patterns

Click to copy
  • Email
    Basic email pattern (not RFC-perfect but practical).
    /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/gi
  • URL (http/https)
    Matches most http(s) URLs.
    /https?:\/\/[^\s/$.?#].[^\s]*/gi
  • IPv4
    Simple IPv4 address (0-255 not strictly enforced).
    /\b(?:\d{1,3}\.){3}\d{1,3}\b/g
  • Hex Color
    3 or 6-digit hex color like #fff or #1a2b3c.
    /#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})/gi
  • Date (YYYY-MM-DD)
    Simple ISO-like date.
    /\b\d{4}-\d{2}-\d{2}\b/g
  • Time (HH:MM[:SS])
    24h time with optional seconds.
    /\b(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?\b/g
  • Slug
    Lowercase letters/numbers separated by dashes.
    /[a-z0-9]+(?:-[a-z0-9]+)*/g
  • HTML Tag
    Opening/closing HTML tags (broad).
    /<\/?[\w-]+[^>]*>/gi
  • UUID v4
    Universally Unique Identifier version 4.
    /\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}\b/g
  • Number (int/float)
    Signed integers or decimals.
    /-?\d+(?:\.\d+)?/g
  • Blank Line
    Empty or whitespace-only lines.
    /^\s*$/gm
  • Words
    Word tokens using \w (letters, digits, underscore).
    /\b\w+\b/g

What is the Common Regex Patterns?

This is a reference library of regular expressions for the patterns developers match most often: email addresses, URLs, phone numbers, dates, IP addresses, hex colours and password rules. Each one is ready to copy, so you do not have to rebuild a fiddly pattern from memory.

Frequently asked questions

Can I trust a copy-pasted email regex?

For form validation, a pragmatic pattern is fine — it catches typos. But no regex fully implements the email specification, and the only real proof an address exists is sending a confirmation message to it. Treat regex as a first filter, not verification.

Do these patterns work in every language?

The syntax shown targets the common subset supported by JavaScript, Python, Java, Go and PCRE. Lookbehind and named groups vary between engines, so test any pattern using those features in your target language.

Related Text & Code

Common Regex Patterns is one of 10 tools in Text & Code on Toolkit Hub, a free collection of browser-based utilities. It requires no account and no installation. Browse all tools.