How to filter Euro numbers with regular expression?

Question:

I try to filter the decimal numbers after the € symbol. So I have this string:

 Delivery date

and so I want to have the decimal numbers:

7,00
3.962,00 4,68
3.304,08 ect

So I try it like this:

pattern = re.compile(r'€s[1-9]d*')

matches = pattern.finditer(test_string)    
 
for match in matches:
    print(match) 

So, if I try it like this. I only get the first number of the number after the euro symbol.

Asked By: mightycode Newton

||

Answers:

You can use a capture group and re.findall, with a pattern matching the dots and comma’s like:

€s(d+(?:.d+)*(?:,d+)?

Or a bit broader, starting with a digit 1-9 as the tried pattern:

€s([1-9][d.,]*)
Answered By: The fourth bird
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.