Community Patterns

Community Library Entry

1

Regular Expression
Created·2021-06-27 14:09
Updated·2023-07-19 20:48
Flavor·PCRE (Legacy)

/
^(?![-])(?!.*[-]$)(?!.*[-]{2})[0-9-]{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.

Assuming the app validates the length.

Submitted by Sowed Castelli