Regex for URL slug
Matches a lowercase URL slug like my-blog-post.
^[a-z0-9]+(?:-[a-z0-9]+)*$
Proof it works
| Sample | Should match | Result |
|---|---|---|
hello-world |
yes | pass |
post-123 |
yes | pass |
Hello-World |
no | pass |
double--dash |
no | pass |
-leading |
no | pass |