Regular Expressions 101

Community Patterns

1...34567...902

Community Library Entry

2

Regular Expression
PCRE (PHP <7.3)

/
(?<![\d\.-])\d(\.\d)?(?!(\.\d)|\d)|(?<![\d\.-])10(?!(\.\d)|\d])
/
g

Description

Matches any number between 0 and 10 (inclusive) with 0 or 1 decimal places. Note that .5 will NOT be matched but 0.5 will. Also 10.X will not be matched, but 10 will.

Submitted by Matt Coubrough - 10 years ago