3 ms·
Hey - could you guys open source that "extract email from crappy Outlook string" code? I would love to use it in my own app.
by swanson 13y ago
Hey - could you guys open source that "extract email from crappy Outlook string" code? I would love to use it in my own app.
- oneeyedpigeon 13y agoYou want them to open-source a regexp?
- swanson 13y agoSure - a basic version isn't super complicated or anything, but there are a lot of edge cases for various email clients, weird names, etc
- philfreo 13y agoWe're using this library: https://github.com/andris9/addressparser https://github.com/andris9/addressparser But we're using it for more than just this scenario. If you're just concerned with this specific case you could come up with a simpler/shorter solution.
- swanson 13y agoThanks - I'll check out that library. I assume you guys use https://github.com/Kicksend/mailcheck https://github.com/Kicksend/mailcheck also?
- jontas 13y agoNot sure what language you use, but it almost definitely supports PCRE. For email addresses, I always use this regex: http://www.regular-expressions.info/email.html http://www.regular-expressions.info/email.html I've yet to run into a problem with it. If you want to extract an address from a larger string, then you need to slightly modify the regex to capture the email address from the string. This is going to depend somewhat on the language you're using, but probably involves wrapping everything between the first \b and the last \b in parentheses. I guess if I were certain that the target text was a "<name>" user@domain.com style string, I probably wouldn't use a regex (unnecessary overhead) and just split on > and trim or something silly like that.
- huhtenberg 13y agoSeriously?