Regex tester / pattern library
Regex: url slug
/^[a-z0-9]+(-[a-z0-9]+)*$/ Test it live How it works
Lowercase words of letters and digits joined by single hyphens — no leading, trailing, or doubled hyphens, which the (-[a-z0-9]+)* structure enforces for free.
Honest caveats
ASCII-only by design. If you need unicode slugs (ürünler), the rules and the regex get much hairier — most systems transliterate to ASCII first instead.
Matches
hello-worldphase-2-completea
Doesn't match
Hello-World-leadingdouble--hyphentrailing-