Regular expression problem with groups

Axel Kowald kowald at molgen.mpg.de
Mon Aug 16 11:08:15 EDT 2004


Hi everybody,

I have a 'simple' problem with regular expressions. Maybe someone can
help me.

import re
bla = 'the the'
obj = re.search('(.+) \1',bla)

obj.group(1) should now be 'the'. Instead obj is none (python 2.3
under windows and 2.1 under linux). The problem seems to be the \1
where I try to reference the first group. However, every tutorial says
this is the correct way to do it !?

Any ideas what I'm doing wrong ?

Many thanks,
   
               Axel



More information about the Python-list mailing list