Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
^(?!-)((?:[a-z0-9]+-?)+)(?<!-)$
/
gm

Description

Matches alphanumeric slugs without repeating dashes

Submitted by Óscar Enríquez - 9 years ago