regex - Python regular expression to exclude the end with string -


i have file rows like

from david.horwitz@uct.ac.za fri jan  4 06:08:27 2008 received: (from apache@localhost) return-path: <postmaster@collab.sakaiproject.org> <source@collab.sakaiproject.org>; 

i trying read each line , use regular expression find domain name, portion after sign @. here code wrote

if re.search('[@]\s+?', line) : org = re.findall('@(\s+)',line)[0] 

but returns following results

uct.ac.za localhost) collab.sakaiproject.org> collab.sakaiproject.org>; 

is there smart way keep domain , not include ')', '>' or '>;' followed domain name?

slight correction - fqdn can include numbers also...

so regex needs slight adjustment to

[@][a-za-z0-9.-]+

full domain rules @ https://en.wikipedia.org/wiki/uniform_resource_locator


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -