java - regex pattern is matching with one of the pattern i cant able to follow? -
i come across regex pattern , matching pattern strings, confused 1 of matched pattern
target: .50 1.50 0.50 10.50 00.50 1.555 pattern: (0|[1-9]\d*)\.\d\d matches with: (4,7:1.50)(9,12:0.50)(14,18:10.50)(21,24:0.50)(26,29:1.55)
what deduce pattern 2 digit after decimal, , before decimal group in first digit either 0 or digit between 1 9, followed empty string or number string...
i think in last second match should 00.50.
what missing??
i think in last second match should 00.50.
what missing??
no, part of regex (0|[1-9]\d*)\.
can rewritten (0\.|[1-9]\d*\.)
, can accept
- one
0
,.
or
[1-9]\d*
,.
if want allow many zeroes before dot use
(0+|[1-9]\d*)\.\d\d ^--one or more zeroes
Comments
Post a Comment