Regular Expression Help

Duncan Booth duncan.booth at invalid.invalid
Sun Mar 16 08:51:41 EDT 2008


"santhosh kumar" <santhosh.cnp at 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)




More information about the Python-list mailing list