Regular Expressions 101

Community Patterns

Whole number or number range | Page number or page range

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 - 6 years ago