My Regex:
\d{0,2}\.?\d{0,3}r?em
string to match:
12123rem
Why is it matching 5 digits?
I want it to match the following pattern only: 12em or 12 rem or 12.345em or 12.345rem
up to 3 decimal places only.
CodePudding user response:
Try this one:
^\d{0,2}(\.\d{1,3})?\s?r?em$
^
- assures we are at the begining of the string^\d{0,2}
zero up to two decimals after begining of string(\.\d{1,3})
optional group of 1 up to 3 digits with.
in front\s?
optional whitespace characterr?
optionalr
characterem
mandatoryem
$
end of the string