Community Patterns

Community Library Entry

1

Regular Expression
Created·2021-06-27 13:53
Flavor·PCRE2 (PHP)

/
^(?![-])(?!.*[-]$)(?!.*[-]{2})[0-9-]+$
/
gm
Open regex in editor

Description

  • Only accept numerics/digits and hyphens, forbidding them at the start and the end of the number, and avoid two consecutive occurrences.
Submitted by Sowed Castelli