[Tutor] RE: problem with re reaching maximum recursions

John Kenyon John.Kenyon@mail.idrive.com
Thu, 23 Aug 2001 14:22:06 -0700

So, immediately after posting this I realized that I could do the search
line-by-line for the first pass and then stick it all back together for the
second pass. Ugly and slow, but it should work. Anybody have any other


>  -----Original Message-----
> From: 	John Kenyon  
> Sent:	Thursday, August 23, 2001 2:17 PM
> To:	'tutor@python.org'
> Subject:	problem with re reaching maximum recursions
> Hello all,
> Have problem maybe somebody can give me some ideas on. I have a script
> that goes through a bunch of files and strips the comments out of them -
> it looks for '//', checks to see that it is not preceeded by ':' and then
> grabs to the end of the line. A second regex then goes through and looks
> for other forms of comments, i.e., "/**".
> The regex I am having a problem with is as follows: slashComment =
> re.compile('(?<!:)\/\/.*(\n)')
> The problem is that when it hits too large a file (not sure exactly how
> big) it throws a runtime exception -- "maximum recursion limit exceeded."
> As far as I can tell in doing a Google search, this is a bug in 2.0 that
> did not exist in 1.5. I tried importing pre instead but it seems to have a
> problem with the negative look back (does anybody know if this was not a
> part of the 1.5 implementation?). I have thought about breaking the file
> up into smaller parts, but I am not sure quite how to do that and in any
> case it would be tricky to make sure that it wasn't split across a
> comment. Any ideas about how to approach this problem, maybe a more
> efficient regex?
> Thanks in advance,
> jck