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

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -