URL Slug Regex Pattern

Example:
^[a-z0-9]+(?:-[a-z0-9]+)*$ Matches: ✓ my-blog-post ✓ article-123 ✗ My_Blog (uppercase/underscore)
Validate URL-friendly slugs: ^[a-z0-9]+(?:-[a-z0-9]+)*$
Try Regex Lab →

FAQs

Why no underscores?

SEO best practice prefers hyphens over underscores in URLs.