JasonB JasonB - 8 months ago 25
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.


You should just use the split method of strings: