GenerateRandomSearch

Regex Pattern Sample Generator

Shows a common validation regular expression alongside a real example string it matches — a quick reference for testing a pattern or learning regex syntax without writing one from scratch every time.

What you'll get

This generator draws from a hand-checked list of 18 entries. Here is a spread of 6 of them, so you can see the style before you generate:

  • ^[\w.+-]+@([\w-]+\.)+[a-zA-Z]{2,}$ — matches: name.tag+sort@example.co.uk
  • ^https?:\/\/[\w.-]+(\/[\w./?%&=-]*)?$ — matches: https://example.com/path?x=1
  • ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$ — matches: Passw0rd123
  • ^\d{1,3}(\.\d{1,3}){3}$ — matches: 192.168.1.10
  • ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$ — matches: 550e8400-e29b-41d4-a716-446655440000
  • ^(0|[1-9]\d*)$ — matches: 0 or 42, not 007

A fixed sample of the list, not a live draw — your own results are picked at random from all 18, without repeating until the list runs out. Original authoring for Generate Random — common validation patterns, not copied from any single library.. Last reviewed 2026-07-18.

How to use this tool

  1. Press generate for a pattern.
  2. Generate again for a different one.

Common use cases

  • Learning regex syntax by example
  • Quick validation-pattern reference
  • Testing a regex engine's behaviour

Limitations and good to know

  • 18 fixed pattern-and-example pairs, chosen for being common rather than exhaustive — there is no field for your own pattern here. The regex string generator and regex tester cover that instead.
  • Only a passing example is shown for each pattern; seeing what it correctly rejects means testing your own near-miss strings against it in the regex tester.
  • Patterns are written for JavaScript's regex flavour. Most translate directly to other languages, but lookaheads and Unicode property escapes do not always carry over unchanged.

Practical tips

  • Test any pattern against strings that should fail as well as ones that should pass; a pattern matching everything looks correct until it does.
  • Watch for catastrophic backtracking in patterns with nested quantifiers — the sample may be fine and your input may not be.

Entries are chosen with your browser's cryptographic random number generator, so every entry on the list is equally likely. How Generate Random works.

Frequently asked questions

Can I test my own pattern against these examples?
Not on this page — it shows fixed pairs rather than accepting input. Paste your own pattern and text into the regex tester to check a match, or use the regex string generator to produce fresh strings that satisfy a pattern you write.
Are these patterns safe to copy into production code?
They cover common shapes correctly, but 'the example matches' is not the same as 'the pattern is complete' — the loose email pattern here, for instance, is explicitly a loose check rather than a strict validator. Verify against your own edge cases before shipping any of them.