python
12 lines · 1 tab
Dr. Elena Vasquez
Apr 2026
1 tab
import re
text = 'INC-102301 resolved on 2026-04-06 after payment failure for order ORD-99182.'
patterns = {
'incident_id': r'INC-[0-9]{6}',
'order_id': r'ORD-[0-9]{5}',
'date': r'\b\d{4}-\d{2}-\d{2}\b',
}
extracted = {name: re.findall(pattern, text) for name, pattern in patterns.items()}
print(extracted)
1 file · python
Explain with highlit
Regex is not glamorous, but it remains one of the fastest ways to turn messy text into useful structured fields. I use it for IDs, dates, codes, and log fragments before reaching for heavier NLP. The important part is making patterns specific enough to avoid silent false positives.
Share this code
Here's the card — post it anywhere.