whats wrong with my reg expression ?

Gabriel Genellina gagsl-py at yahoo.com.ar
Mon Jan 15 19:05:20 EST 2007


At Monday 15/1/2007 20:43, Gert Cuykens wrote:

>PS i also cant figure out what is wrong here ?
>
>         rex=re.compile('^"(?P<value>[^"]*)"$',re.M)
>         for v in l:
>             v=rex.match(v).group('value')
>             v=v.replace('""','"')
>         return(l)
>
>     v=rex.match(v).group('value')
>AttributeError: 'NoneType' object has no attribute 'group'

match() returns None when there is no match, so you have to split 
that in two steps:

m = rex.match(v)
if m:
     v = m.group('value')
else:
     # no match found!


-- 
Gabriel Genellina
Softlab SRL 


	

	
		
__________________________________________________ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 




More information about the Python-list mailing list