On 6 Oct 2006 23:09:08 -0700, MonkeeSage <[EMAIL PROTECTED]> wrote: > > > On Oct 6, 11:33 pm, hanumizzle <[EMAIL PROTECTED]> wrote: > > import re > > > > <snip> > > > > if line.startswith('instr'): > > p = re.compile(r'(\d+)\s+;(.*)$') > > m = p.search(line) > > > > return (m.group(1), m.group(2)) > > You probably don't want startswith, in case there are initial spaces in > the line.
Pardon me; I am not very familiar with file format in question. > Also, since the regexp is single use, you can just use the > re.search class method, which will compile the regexp implicitly. Cool. > May > also want to strip the second grouped match, in case of trailing > spaces. Cosmetic, but good idea. -- Theerasak -- http://mail.python.org/mailman/listinfo/python-list