Duncan Booth
3/16/2008 12:52:00 PM
"santhosh kumar" <santhosh.cnp@gmail.com> wrote:
> I have text like ,
> STRINGTABLE
> BEGIN
> ID_NEXT_PANE "Cambiar a la siguiente sección de laventana
> \nSiguiente sección"
> ID_PREV_PANE "Regresar a la sección anterior de
> laventana\nSección anterior"
> END
> STRINGTABLE
> BEGIN
> ID_VIEW_TOOLBAR "Mostrar u ocultar la barra de
> herramientas\nMostrar/Ocultar la barra de herramientas"
> ID_VIEW_STATUS_BAR "Mostrar u ocultar la barra de
> estado\nMostrar/Ocultar la barra de estado"
> END
> ................................
> ....................................
> ..........................................
> and i need to parse from STRINGTABLE to END as a list object. whatkind of
> regular expression should i write.
>
I doubt very much whether you want any regular expressions at all. I'd do
something alone these lines:
find a line=="STRINGTABLE"
assert the next line=="BEGIN"
then until we find a line=="END":
idvalue = line.strip().split(None,1)
assert len(idvalue)==2
result.append(idvalue)