Expanding regexps

Klaus Alexander Seistrup spam at magnetic-ink.dk
Wed Oct 29 18:09:32 EST 2003


Diez B. Roggisch wrote:

>> Is there a way to "expand" simple regexps?  Something along
>> the lines of:
>
> What would you expect to be the result of this rex:
>
> r'a*' 
>
> ?
>
> The language accepted by this is of unlimited size - where do
> you stop?

That's why I wrote "simple regexps", I'm fully aware that it would
be very difficult to expand all possible patterns - and that's not
what I need.

But to answer your question, even though it was probably rhetorical,
sre_parse looks at it from this angle:

#v+
>>> import sre_parse
>>> sre_parse.parse(r'a*')
[('max_repeat', (0, 65535, [('literal', 97)]))]
>>> 
#v-

  // Klaus

-- 
 ><> 	unselfish actions pay back better




More information about the Python-list mailing list