Issue
I'm pretty new to python and regex, so forgive me if this is elementary. I am trying to match a pattern to allow for unlimited numbers on the left side of the decimal and two on the right. This is the pattern I'm dealing with.
$44.01Bobby N. ...1111
It might also be something like.
$4354.01Bobby N. ...1241
I am able to match the 44.01 by simply typing this, which is what I want.
\d*\.\d\d
However, I end out matching .11
as well, which I don't want.
Solution
The problem is you are using \d*
which matches: no digit, one digit or more that one digits, so .11
is a valid match. To ensure matching at least one digit before the .
try using \d+\.\d\d
. The \d+
matches one or more than one digit.
Answered By - Jorge Morgado
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.