regsub.gsub eats backslashes

Justin Sheehy dworkin at ccs.neu.edu
Wed Mar 29 11:21:17 EST 2000


Richard van de Stadt <stadt at cs.utwente.nl> writes:

> p = template
> p = regsub.gsub ('_PROGRAMCOMMITTEE_', programcommittee, p)

> Then, the _REFEREES_ keyword is being replaced by this generated
> list, again using regsub.gsub(). To my surprise, to end up with
> 2 backslashes in the resulting file, I need to put 10 (!)
> backslashes in the regsub that does the column stuff.
> 
> I can't figure out why regsub eats so many backslashes. Seeing the
> result of the PROGRAMCOMMITTEE substitution, 8 backslashes might
> have been more reasonable, because there is an extra regsub.gsub().
> 
> Does anyone have a clue? Is there a better way to do this?

Why are you using regexes?  Is there a reason why string.replace() won't do?

Using regexes uneccessarily is the cause of many programming headaches.

-Justin

 




More information about the Python-list mailing list