diff --git a/price_parser/parser.py b/price_parser/parser.py index 4e125ff..0e8c0cf 100644 --- a/price_parser/parser.py +++ b/price_parser/parser.py @@ -323,7 +323,7 @@ def extract_price_text(price: str) -> Optional[str]: if price.count("€") == 1: m = re.search( r""" - [\d\s.,]*?\d # number, probably with thousand separators + [\d\s.,']*?\d # number, probably with thousand separators \s*?€(\s*?)? # euro, probably separated by whitespace \d(?(1)\d|\d*?) # if separated by whitespace - search one digit, # multiple digits otherwise @@ -337,7 +337,7 @@ def extract_price_text(price: str) -> Optional[str]: m = re.search( r""" - ([.]?\d[\d\s.,]*) # number, probably with thousand separators + ([.]?\d[\d\s.,']*) # number, probably with thousand separators \s*? # skip whitespace (?:[^%\d]|$) # capture next symbol - it shouldn't be % """, @@ -347,6 +347,7 @@ def extract_price_text(price: str) -> Optional[str]: if m: price_text = m.group(1).rstrip(",.") + price_text = price_text.replace("'", "") return ( price_text.strip() if price_text.count(".") == 1 diff --git a/tests/test_price_parsing.py b/tests/test_price_parsing.py index 4329a9d..eadb235 100644 --- a/tests/test_price_parsing.py +++ b/tests/test_price_parsing.py @@ -98,6 +98,8 @@ def idfn(val): Example(None, "13800 ₶", "₶", "13800", 13800), Example(None, "12,000원", "원", "12,000", 12000), Example(None, "3,500円", "円", "3,500", 3500), + Example(None, "CHF 1'049,95", "CHF", "1049,95", 1049.95), + Example(None, "€1'049,95", "€", "1049,95", 1049.95), ]