Possible Duplicate:
Python Regex Use - How to Get Positions of Matches
I am new to python. I have written program where I used regular expression to extract the exact number from webpage using command line arguments.First argument should be 'Amount' second should be 'From' third should be 'To'.I should extract exact number from site "http://www.xe.com/ucc/convert/?Amount=1&From=INR&To=USD" where the converted amount should be extracted. The code is:
import requests
import re
import sys
amount=sys.argv[1]
from_=sys.argv[2]
to=sys.argv[3]
r = requests.get("http://www.xe.com/ucc/convert/?Amount=%(amount)s&From=%(from_)s&To=%(to)s"%{"amount":amount,"from_":from_,"to":to})
dataCrop=re.findall('[0-9,]+\.[0-9]+',r.text)
if amount<'1':
print dataCrop[15]
else:
print dataCrop[11]
But the problem is I should not use exact position that is
if amount<'1':
print dataCrop[15]
else:
print dataCrop[11]
Instead of that I should modify my regular expression. How can I write regular expression for this? I cant use beautiful soup.