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
Post a Comment