regex - Remove prefix from name python -


names = [ 'lic. sebastiÁn lastiri', 'ing. agr. roberto daniel rodrÍguez', 'c.p.n. julio domingo burak', 'ingeniero hidrÁulico vÍctor agustÍn porrino' ] 

i have such list names, need remove prefix ('lic', 'c.p.n' etc) name (this sample there lot of prefixes in such format)

output shell :

'sebastiÁn lastiri'

i have tried :

for in names:    if '.' in i:         i.split('.')[1] 

but works when there 1 dot in prefix how solve this

here solution issue:

import re  names = [     'lic. sebastiÁn lastiri',     'ing. agr. roberto daniel rodrÍguez',     'c.p.n. julio domingo burak',     'ingeniero hidrÁulico vÍctor agustÍn porrino' ]  new_names = [re.sub("^\s+", "", i.split(".")[-1]) in names]  print new_names # [sebastiÁn lastiri', roberto daniel rodrÍguez', julio domingo burak', 'ingeniero hidrÁulico vÍctor agustÍn porrino'] 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -