On 30/9/2013 16:29, Leena Gupta wrote:

> 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)

That's not a format, it's a infinitesimally tiny sample.  But if we
trust in this sample, you don't need a regex at all.  The state and
country are in the last 7 characters of the string:

countr = text[-3:-1]
state = text[-7:-5]

I could be off by 1 or 2, but you get the idea.

if this isn't good enough, then either supply or give a reference to a
specification for how "code" is encoded.

(If it does indeed need a regex, someone else will have to help)

-- 
DaveA


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to