regex - Split String with Python Regexp -


if have string like:

"|cll23|str. california|cll12|av. philadelfia 438|cll10|av. 234 depto 34|"  

i need separate string form next:

cll23|str.california  cll12|av. texas 345  cll10|av. 234 depto 24 

try following form:

r=re.compile('(?<=[|])([\w]+)')  v_sal=r.findall(v_campo) print v_sal 

result:

['cll23', 'cll12', 'cll10'] 

that way rest of string in python?

let's define string:

>>> s = "|cll23|str. california|cll12|av. philadelfia 438|cll10|av. 234 depto 34|" 

now, let's print formatted form:

>>> print('\n'.join('cll' + word.rstrip('|') word in s.split('|cll') if word)) cll23|str. california cll12|av. philadelfia 438 cll10|av. 234 depto 34 

the above divides on |cll. seems work sample input.