flaibo
Data Structure

Regex Pattern

Extract all email addresses from a large text file of customer support emails, using Python's re module

No card required

What this brief specifies

Context

The goal is to build a contact list out of 18 months of accumulated support ticket text.

Edge cases

The pattern has to catch emails inside parentheses, emails followed immediately by punctuation, mailto: links, and plus-addressed accounts like user+tag@domain.com.

The bar to hit

It needs to capture 99%+ of legitimate emails, false positives are fine since they'll be validated later, but it can't catastrophically backtrack on files over 10MB.

What makes this hard

The quality goal here runs against the usual instinct for email matching, most regex tutorials optimize for strict, RFC-correct patterns that reject anything malformed, while this one wants the opposite trade, catch 99%+ of real emails and accept false positives, since those get validated downstream anyway. That permissive stance is exactly what raises the risk of catastrophic backtracking in Python's re module once the pattern also has to handle the stated edge cases: an email wrapped in parentheses, one followed immediately by punctuation, a mailto: link, or a plus-addressed account, each pushing toward more nested or optional matching, the same shape that causes exponential slowdowns on large input. And the input isn't a small sample, it's 18 months of accumulated support ticket text, so the 10MB-plus scale requirement is the actual file size the pattern has to survive, not a hypothetical stress test.

FounderConsultantMarketingCorporateSme

Frequently asked questions

The next extraction job that has to favor catching everything over catching only clean matches, while still surviving a large file without hanging, benefits from a pattern built against the real edge cases and the real file size up front, rather than a textbook regex that breaks on the first mailto: link or plus-addressed account it meets.

Ready to try this in Flaibo?

Get started free

Your context everywhere