python re.sub

Andrew M. Kuchling akuchlin at cnri.reston.va.us
Thu May 6 16:05:08 EDT 1999


Ivan Van Laningham writes:
>"Jerry L. Bash" wrote:
>> At any rate, the following is mostly taken from the HOWTO.  It appears
>> that the default 'count' is not working as I expected, resulting in
>> not making substitutions for all cases.
>> 
>> Python 1.5.2 (#2, Apr 26 1999, 09:21:48)  [GCC 2.8.1] on irix646
>> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>> >>> import re
>> >>> p = re.compile( '(blue|white|red)')
>> >>> p.sub( 'colour', 'blue socks and red shoes')
>> 'blue socks and red shoes'

	After looking at re.py a bit, here's a suggestion: What does
'import sys ; print sys.maxint' output?  The re.py code contains a
statement like "if count==0: count = sys.maxint", and I'm wondering if
perhaps sys.maxint is coming out negative, which would explain these
symptoms.  Why sys.maxint might be negative, I don't know.

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
You cannot slander human nature; it is worse than words can paint it.
    -- Charles Haddon Spurgeon






More information about the Python-list mailing list