Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

/
^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$
/
gm

Description

This should work:

^([a-zA-Z0-9]-[a-zA-Z0-9])+$ Also if you want to have exactly 135 hyphens:

^([a-zA-Z0-9]-[a-zA-Z0-9]){135}$ or if you want to have at least 23 hyphens but not more than 54 hyphens:

^([a-zA-Z0-9]-[a-zA-Z0-9]){23,54}$

Submitted by anonymous - 6 years ago