regsub.gsub eats backslashes
Richard van de Stadt
stadt at cs.utwente.nl
Fri Mar 31 03:43:52 EST 2000
Justin Sheehy wrote:
>
> 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?
There was 1 reason to use regsub.gsub(): I didn't know string.replace()
Thanks.
Richard.
More information about the Python-list
mailing list