Community Patterns

Community Library Entry

2

Regular Expression
Created·2016-09-10 17:57
Flavor·ECMAScript (JavaScript)

/
^\s*(\d+(?:\.\d+)?)(?:\s*\-\s*(\d+(?:\.\d+)?))?\s*$
/
g
Open regex in editor

Description

Allows either a number (e.g. "1", "1.01") or a range (e.g. "1-2", "1.0 - 1.3"). Also allows whitespace on either side of the numbers.

Submitted by Mark Newcomb