problem with split

MonkeeSage MonkeeSage at
Sat Oct 7 08:09:08 CEST 2006

On Oct 6, 11:33 pm, hanumizzle <hanumiz... at> wrote:
> import re
> <snip>
> if line.startswith('instr'):
>   p = re.compile(r'(\d+)\s+;(.*)$')
>   m =
> return (,

You probably don't want startswith, in case there are initial spaces in
the line. Also, since the regexp is single use, you can just use the class method, which will compile the regexp implicitly. May
also want to strip the second grouped match, in case of trailing

if 'instr' in line:
  m ='(\d+)\s+;(.*)$', line)
  if m:
    return (,


More information about the Python-list mailing list