How to get the "longest possible" match with Python's RE module?

Fredrik Lundh fredrik at pythonware.com
Tue Sep 12 06:23:14 EDT 2006


Licheng Fang wrote:

The idea is like this:
> 
> (*INT) = \d+
> (*DECIMAL) = (*INT)\.(*INT)
> (*FACTION) = (*DECIMAL)/(*DECIMAL)
> (*NUMERALS) = (*FACTION)|(*DECIMAL)|(*INT)
> ... ...
> 
> What's inside the sytactically wrong (* and ) is something to be
> replaced, and then I wrote a little script to do the string
> substitution

what's hiding under those ellipses?  things like "TERM" and "FACTOR" and 
"EXPRESSION", perhaps?

</F>




More information about the Python-list mailing list