News for hackers. Stuff that matters.
Re:Show HN: I wrote a book on Python regular expressions by just_myles on Thursday August 08, 2019 @02:16PM (#20647052)
I use the below to extract email addresses. Took from some website some time ago and made super light changes to it. Not sure if this is the best but it has served me fairly well.

email_reg = re.compile (r'''

([a-zA-Z0-9._%+-]+ #First name and last name

@ #@ sign

[a-zA-Z0-9._%+-]+ #domain name

\.[a-zA-Z]{2,10}) #.com

''',re.VERBOSE)

Re:Show HN: I wrote a book on Python regular expressions by _eht on Thursday August 08, 2019 @03:16PM (#20647621)
You should allow “$” on the left; as per the RFC...
Re:Show HN: I wrote a book on Python regular expressions by just_myles on Thursday August 08, 2019 @03:52PM (#20647994)
Why I hate regex :) . You think you know it but, you never really do.
Re:Show HN: I wrote a book on Python regular expressions by nerdponx on Thursday August 08, 2019 @10:25PM (#20650851)
That's about the email RFC, not about regex syntax.
Re:Show HN: I wrote a book on Python regular expressions by just_myles on Friday August 09, 2019 @12:16PM (#20655704)
Ok cool.
Re:Show HN: I wrote a book on Python regular expressions by wwwhizz on Thursday August 08, 2019 @03:09PM (#20647560)
I would not allow the % sign.