HomeRegex LibrarySEO Friendly URL Slug Regex
100% Client-Side β€’ 0 B Data Leaves Browser
web

SEO Friendly URL Slug Regex

Enforces lowercase alphanumeric words separated only by single hyphens with no trailing dashes.

Regular Expression Pattern:
/^[a-z0-9]+(?:-[a-z0-9]+)*$/
Valid Match Example:
universal-developer-tools-2026
Invalid / Non-Match Example:
Invalid--Slug_Name

Regex Syntax Breakdown & Explanation

  • β€’^[a-z0-9]+ : Starts with lowercase letter or digit
  • β€’(?:-[a-z0-9]+)*$ : Hyphen followed by alphanumeric segment repeated

Implementation in Popular Languages

JavaScript / TypeScript
const regex = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
const isValid = regex.test("universal-developer-tools-2026");
console.log(isValid); // true
Python (re)
import re

pattern = r"^[a-z0-9]+(?:-[a-z0-9]+)*$"
match = re.match(pattern, "universal-developer-tools-2026")
print(bool(match)) # True
Go (regexp)
package main
import (
  "fmt"
  "regexp"
)

func main() {
  re := regexp.MustCompile(`^[a-z0-9]+(?:-[a-z0-9]+)*$`)
  fmt.Println(re.MatchString("universal-developer-tools-2026"))
}
Frequently Asked Questions

Frequently Asked Questions

Everything you need to know regarding specifications, syntax, and security best practices.

The regular expression pattern is /^[a-z0-9]+(?:-[a-z0-9]+)*$/. Enforces lowercase alphanumeric words separated only by single hyphens with no trailing dashes.