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.
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.,]*)
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.
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.,]*)