Hello, I have a TSV file that has the city,state,country information in this format: Name Display name Code San Jose SJC SJC - SJ (POP), CA (US) San Francisco SFO SFO - SF, CA (US)
I need to extract the state and country for each city from this file. I'm trying to do this in python by using the following Regex: s=re.search(',(.*?)\(',text) if s: state=s.group(1).strip() c=re.search('\((.*?)\)',text) if c: country=c.group(1).strip() This works well for the state. But for country for San Jose, it brings the following: country = POP I think it maybe better to search from the end of the string,but I am unable to get the right syntax. Could you please share any pointers? Thanks!
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor