before claude
This commit is contained in:
@@ -17,6 +17,18 @@ def parse_price_text(text: str) -> Optional[float]:
|
||||
if not text:
|
||||
return None
|
||||
|
||||
euro_suffix = re.search(r"([0-9 .,]+)\s*€\s*(\d{2})\b", text)
|
||||
if euro_suffix:
|
||||
integer_part = euro_suffix.group(1)
|
||||
decimal_part = euro_suffix.group(2)
|
||||
integer_clean = re.sub(r"[^\d]", "", integer_part)
|
||||
if integer_clean:
|
||||
cleaned_decimal = f"{integer_clean}.{decimal_part}"
|
||||
try:
|
||||
return float(cleaned_decimal)
|
||||
except ValueError:
|
||||
pass
|
||||
# Fallback to original replacement if suffix logic fails
|
||||
text = re.sub(r"(\d)\s*€\s*(\d)", r"\1,\2", text)
|
||||
cleaned = text.replace("\u00a0", " ").replace("\u202f", " ").replace("\u2009", " ")
|
||||
cleaned = "".join(ch for ch in cleaned if ch.isdigit() or ch in ".,")
|
||||
|
||||
Reference in New Issue
Block a user