Re: Help to find a regular expression to parse po file

2009-07-06 Thread gialloporpora
Risposta al messaggio di MRAB : gialloporpora wrote: Hi all, I would like to extract string from a PO file. To do this I have created a little python function to parse po file and extract string: import re regex=re.compile("msgid (.*)\\nmsgstr (.*)\\n\\n") m=r.findall(s) where s is a po file

Re: Help to find a regular expression to parse po file

2009-07-06 Thread gialloporpora
Risposta al messaggio di Hallvard B Furuseth : I don't know the syntax of a po file, but this works for the snippet you posted: arg_re = r'"[^\\\"]*(?:\\.[^\\\"]*)*"' arg_re = '%s(?:\s+%s)*' % (arg_re, arg_re) find_re = re.compile( r'^msgid\s+(' + arg_re + ')\s*\nmsgstr\s+(' + arg_re + '

Re: Help to find a regular expression to parse po file

2009-07-06 Thread MRAB
gialloporpora wrote: Hi all, I would like to extract string from a PO file. To do this I have created a little python function to parse po file and extract string: import re regex=re.compile("msgid (.*)\\nmsgstr (.*)\\n\\n") m=r.findall(s) where s is a po file like this: msgctxt "write ubiqu

Re: Help to find a regular expression to parse po file

2009-07-06 Thread Hallvard B Furuseth
gialloporpora writes: > I would like to extract string from a PO file. To do this I have created > a little python function to parse po file and extract string: > > import re > regex=re.compile("msgid (.*)\\nmsgstr (.*)\\n\\n") > m=r.findall(s) I don't know the syntax of a po file, but this works

Help to find a regular expression to parse po file

2009-07-06 Thread gialloporpora
Hi all, I would like to extract string from a PO file. To do this I have created a little python function to parse po file and extract string: import re regex=re.compile("msgid (.*)\\nmsgstr (.*)\\n\\n") m=r.findall(s) where s is a po file like this: msgctxt "write ubiquity commands.descripti