maximum recursion in "re" module?

CJ Kucera pez at apocalyptech.com
Tue Oct 16 10:17:00 EDT 2001


On Mon Oct 15 20:13:25 2001, Skip Montanaro wrote:
> 
>     CJ>   startString = ".*?Lo Fi Play</phrase></a> <phrase><a href=\""
>     ...    
>     CJ>   mp3String = re.compile(startString, re.I).sub("", mp3String, 1)
> 
> Why do you need the ".*?" part of the re?  I'd try this:

Well, basically what I want to go is get one URL out of the big
mess o' HTML I'm trying to pull back.  This URL comes directly after
the "startString" bit, so what I was originally doing is replacing
EVERYTHING up to and including startString with nothing.  What I
stripped out because it wasn't causing problems was that there's an
"endString" too which lets the program know where the URL I want ends.
Using the ".*?" seemed to be the easiest way to do that to me . . .

> If you can get by without it, I think that will cure your problems.  If not,
> you can always import pre instead:
> 
>     import pre as re

I'm assuming that that's "previous re" or something?  Like the
Python 1.x version of re (as opposed to 2.x)?  In any case, I'll
give that a try.  Thanks!

-CJ




More information about the Python-list mailing list