Re: String replacements

Jaap Vermeulen (jaap@sequent.com)
Fri, 31 Mar 95 22:36:48 GMT

In <glencD67r2D.n7@netcom.com> glenc@netcom.com (Glen Collins) writes:

>for the resulting file to be written as sampled above. I can use a
>sed script to do this. sample:
>
>s/\\n/\\\\n/g
>
>This will work, but I want to use python. Now I have tried the following:
>
>regsub.gsub('\n','\\n',<var>)
>
>Will this even work? I have even tried to double and tripple the "\" but
>it does not seem to work. Any ideas?

You will need to quadruple the back-slash. See tokenize.py. The
following will work:

regsub.gsub('\n','\\\\n',<var>)

Good luck,

-Jaap-

-- 
Jaap Vermeulen                      .   Sequent Computer Systems, Inc
        Telephone: (503) 578-4404   |   Platform Management , M/S DES2-731
        Fax      : (503) 578-3228   |   15450 SW Koll Parkway
        Email    : jaap@sequent.com |   Beaverton, Oregon  97006-6063