Regular Expressions 101

Community Patterns

Match Decimal allow single leading/tailing 0

1

Regular Expression
ECMAScript (JavaScript)

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

Description

Matches a decimal, but only allows for leading/tailing Zeros if they are the first digit to precede or follow the decimal point

Submitted by Doom87er - 6 years ago