Reputation: 1709
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..
Upvotes: 0
Views: 458
Reputation: 143102
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.
Upvotes: 1
Reputation: 56674
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").
Upvotes: 2
Reputation: 7271
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)
Upvotes: 0