In <[EMAIL PROTECTED]>, Daniel Schüle wrote:

> this is the pattern
> 
> pattern = 
> re.compile(r'^\s*package\s+(?P<name>\w+)\s+is\s+(?P<content>.*?)\s+end(\s+package)?(\s+(?P=name))?\s*;',
>  
> re.DOTALL | re.MULTILINE | re.IGNORECASE)
> 
> and the problem is that
>     package TEST is xyz end;
> works but
>     package TEST123 is xyz end;
> fails

For me both work:

In [11]:pattern = (
t>.*?)\s+end(\s+package)?(\s+(?P=name))?\s*;', )\s+is\s+(?P<conten
   .11.:re.DOTALL | re.MULTILINE | re.IGNORECASE))

In [12]:pattern.match('package TEST is xyz end;')
Out[12]:<_sre.SRE_Match object at 0x405b1650>

In [13]:pattern.match('package TEST123 is xyz end;')
Out[13]:<_sre.SRE_Match object at 0x405b15f8>

I have copy and pasted you code.

For debugging re's in Python you might take a
look at http://kodos.sourceforge.net/

Ciao,
        Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to