URL Slug
beginnerMatches URL-safe slug strings like 'my-blog-post-title'.
urlslugseovalidation
Pattern
/^[a-z0-9]+(?:-[a-z0-9]+)*$/Try It
0 of 8 strings matched
Explanation
Matches lowercase alphanumeric strings with hyphens as word separators. No leading/trailing hyphens, no consecutive hyphens. Common format for SEO-friendly URLs.
Test Strings
Matching
- my-blog-post
- hello-world-123
- single
Non-matching
- -leading
- trailing-
- UPPERCASE
- has spaces
- double--hyphen
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);Common Variations
With underscores
^[a-z0-9]+(?:[-_][a-z0-9]+)*$Also allows underscores as separators