Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
^((100((\.|,)[0-9]{1,2})?)|([0-9]{1,2}((\.|,)[0-9]{0,2})?))$
/

Description

A number between 0 and 100 (including them) with up to two decimals. The decimal separator can be . or , . Usefull for percentage.

Submitted by anonymous - 10 years ago