-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_regex3.py
More file actions
25 lines (22 loc) · 940 Bytes
/
test_regex3.py
File metadata and controls
25 lines (22 loc) · 940 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
import re
text = """
JUBILAZO $1.000.000: $720 MILLONES
JUBILAZO $500.000: $240 MILLONES
JUBILAZO 50 años $1.000.000: $600 MILLONES
JUBILAZO 50 años $500.000: $0 MILLONES
"""
_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)}")