-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_regex2.py
More file actions
29 lines (24 loc) · 908 Bytes
/
test_regex2.py
File metadata and controls
29 lines (24 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import re
text = """
Jubilazo de $1.000.000
$720Millones
Jubilazo de $500.000
$240Millones
Jubilazo Aniversario de $1.000.000
$600Millones
"""
_LABEL_PATTERNS = {
"Loto Clásico": r"Loto\s+Cl[aá]sico",
"Recargado": r"Recargado",
"Revancha": r"Revancha",
"Desquite": r"Desquite",
"Jubilazo $1.000.000": r"Jubilazo(?:\s*(?:de\s*)?\$?1\.000\.000)?(?!\s*(?:50\s*a(?:ñ|n)os|Aniversario))",
"Jubilazo $500.000": r"Jubilazo\s*(?:de\s*)?\$?500\.000",
"Jubilazo 50 años $1.000.000": r"Jubilazo\s*(?:50\s*a(?:ñ|n)os|Aniversario)(?:\s*de)?\s*\$?1\.000\.000",
"Jubilazo 50 años $500.000": r"Jubilazo\s*(?:50\s*a(?:ñ|n)os|Aniversario)(?:\s*de)?\s*\$?500\.000",
}
for label, pattern in _LABEL_PATTERNS.items():
regex = re.compile(pattern + r"[^0-9$]{0,50}\$?([\d\.,]+)", re.IGNORECASE)
match = regex.search(text)
if match:
print(f"{label}: {match.group(1)}")