I'm trying to receive the prices from the following string:
"€29,95 ipv €69,95 – ezCast M2 Original "
With the following regex:
[\$\£\€](\d+(?:.\d{1,2})?)
According to regex testers the above regex works fine (I receive 29,95 and 69,95 without currency, so that's good)... But in python it doesn't. I think it's because of the fact python unicodes strings. Because if I print the string on my screen I get:
[u'\u20ac29,95 ipv \u20ac69,95 \u2013 ezCast M2 Original']
I tried the following codes:
p = re.findall('[\$\£\€](\d+(?:.\d{1,2})?)',str(prices))
p = re.findall(u'[\$\£\€](\d+(?:.\d{1,2})?)',str(prices))
p = re.findall(ur'[\$\£\€](\d+(?:.\d{1,2})?)',str(prices))
p = re.findall(r'[\$\£\€](\d+(?:.\d{1,2})?)',str(prices))
None of those work... But the one below DOES work:
p = re.compile('(\d+(?:.\d{1,2})?)')
#
for m in p.findall(str(prices)):
print m
But then I receive ALL numbers and I just want the numbers behind a currency.
Anyone who can help me out?
r'[$£€](\d+(?:\.\d{1,2})?)'