JasonB JasonB - 1 year ago 77
Python Question

python regex get first part of an email address

I am quite new to python and regex and I was wondering how to extract the first part of an email address upto the domain name. So for example if:


I would like the regex result to be (taking into account all "sorts" of email ids i.e including numbers etc..):


I get the idea of regex - as in I know I need to scan till "@" and then store the result - but I am unsure how to implement this in python.

Thanks for your time.

Answer Source

You should just use the split method of strings:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download