regex for url slug
match a url slug
          ^[a-z0-9]+(?:-[a-z0-9]+)*$
        
Regex Flags
 
        global match
        ? 
 
        ignore case
        ? 
 
        multiline
        ? 
 
        dotAll
        ? 
 
        unicode
        ? 
 
        sticky
        ? 
best-way
best-d4y
my-1ife
@t-the-sky
at-the--sky
-
a
fly-
A ‘slug' is the part that comes at the very end of a URL, and refers to a specific page or post. Usually a combination of word that separated with hyphen
This expression can be used to validate an url slug with only lowercase alphabet or numbers on each word.
For example, in https://github.com/geongeorge/i-hate-regex , i-hate-regex is the slug.
Cheatsheet
| expr | usage | 
|---|---|
| /[a-zA-Z]/ | matches all lowercase and uppercase letters | 
| /ab*c/ | matches zero or more repetitions of "b" (matches "abc", "abbbbc", "ac") | 
| /ab+c/ | matches one or more repetitions of "b" (matches "abc", "abbbbc", but not "ac") | 
| /^/ | matches beginning of a line | 
| /$/ | matches end of a line | 
| /(?:hard)?work/ | matches "work" or "hardwork" but is a non-capturing group | 
          iHateRegex
        
 
          by
          geon