Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

/
^(\d+?)(?:\-(\d+?))?$
/
g

Description

Allows a whole number (25) or range (25-30) with no whitespace.

See below for whitespace and decimals: https://regex101.com/library/fT2hY3

Submitted by anonymous - 7 years ago