Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

/
(?<![.\d])(?:(?:0*1(?:[.]0+)?)|(?=0+(?:[^\d.]|$))0+|0*[.]\d+)(?![\d.])
/
gm

Description

Handles basic decimal numbers on the interval [0, 1]—e.g. 1, 0, 0.0, 0.4, 1.00—as well as stranger formatting like 00000.1 or 000001.000000.

Submitted by disk0 - 3 years ago