python - searching for doubles with regular expressions -
this question has answer here:
is there regular expression match floating point numbers not if part of construct 15.01.2016?
re.match(rex, s)
should successful if s
be
1.0a 1.b .1
and not successful s
like
1.0.0 1.0.1 20.20.20.30 12345.657.345
edit: crucial part combination of constrains: "[0-9]*\.[0-9]*"
, not part of "[0-9]+\.[0-9]+(\.[0-9]+)+"
you can use regex based on arounds in python:
(?<![\d.])(?:\d*\.\d+|\d+\.\d*)(?![\d.])
(?![\d.])
lookahead assertion fail match if next char dot or digit(?<![\d.])
lookbehind assertion fail match if previous char dot or digit
Comments
Post a Comment