I'm new with python and regular expressions.
I have this regular expressions and i don't know what is the purpose of this
r'(\d+)\.(\d*)'
all I know is it matches a digit from 0 to 9.
can anyone help me explain it?
thanks..
I'm new with python and regular expressions.
I have this regular expressions and i don't know what is the purpose of this
r'(\d+)\.(\d*)'
all I know is it matches a digit from 0 to 9.
can anyone help me explain it?
thanks..
It matches a string containing one or more decimal digits, followed by a decimal place, followed by 0 or more decimal digits - ie, a floating-point number. It returns the two strings of digits.
For example, if you try it on the string "123.456" it will return ("123", "456").
r'(\d+)\.?(\d*)' would make more sense to catch floats.This looks for at least one digit (or more) followed by a decimal point and zero or more digits after it.
This quick reference/cheat sheet might be helpful looking up the parts that make up regular expressions.
This is a very nice Google video tutorial on regular expressions.
http://docs.python.org/library/re.html read it up. It will definitely be more enlightening than any answer you get here. That though matches digits (1 or more) followed by a decimal point and some further numbers (0 or more)