Regex Generator

Gives you a tested regular expression for a common format, along with an explanation of what it does and does not accept, plus one example it matches and one it rejects.

Ad placeholder: Resp_Horizantal_1 (horizontal)
Ad placeholder: Resp_Square_1 (square)

Gives you a tested regular expression for a common format, along with an explanation of what it does and does not accept, plus one example it matches and one it rejects.

Name any of: canadian-postal, duplicate-word, email, hex-colour, html-tag, ipv4, iso-date, iso-datetime, semver, slug, strong-password, time24, uk-postcode, url, us-zip, uuid. Runs entirely in your browser — nothing is sent to a server.

Use cases

  • Getting a validation pattern without writing one from scratch
  • Checking how a well-known pattern handles the awkward cases

Examples

A URL slug

slug
{
  "name": "slug",
  "regex": "^[a-z0-9]+(?:-[a-z0-9]+)*$",
  "description": "A lowercase URL slug with single hyphens between words.",
  "example": {
    "matches": "my-first-post",
    "rejects": "My-First-Post"
  }
}

FAQ

Is my data sent to a server?

No — this tool runs entirely in your browser.

Why is the email pattern so simple?

Because a full RFC 5322 pattern is enormous and accepts addresses no real service does. This one checks the shape people actually mean, and the only certain test of an address is sending mail to it.

Are these patterns anchored?

Most are, with ^ and $, so they validate a whole value. The html-tag and duplicate-word patterns are not, since they are meant for scanning within a longer text.

Can it build a pattern from my examples?

No. This is a library of patterns that have been checked against cases that are known to pass and to fail. Use the Regex Tester to try one against your own data.