Re: inserting \ in regular expressions [solved]

2011-11-05 Thread Ross Boylan
On Wed, 2011-10-26 at 12:48 -0700, Ross Boylan wrote: I want to replace every \ and (the two characters for backslash and double quotes) with a \ and the same character, i.e., \ - \\ - \ I'd like to thank Ian, Dave, MRAB, and John for their helpful responses. I hadn't realized the

Re: inserting \ in regular expressions

2011-10-27 Thread John Roth
On Oct 26, 2:47 pm, Dave Angel d...@davea.name wrote: On 10/26/2011 03:48 PM, Ross Boylan wrote: I want to replace every \ and (the two characters for backslash and double quotes) with a \ and the same character, i.e., \ -  \\ -  \ I have not been able to figure out how to do

inserting \ in regular expressions

2011-10-26 Thread Ross Boylan
I want to replace every \ and (the two characters for backslash and double quotes) with a \ and the same character, i.e., \ - \\ - \ I have not been able to figure out how to do that. The documentation for re.sub says repl can be a string or a function; if it is a string, any backslash escapes

Re: inserting \ in regular expressions

2011-10-26 Thread Ian Kelly
On Wed, Oct 26, 2011 at 1:48 PM, Ross Boylan r...@biostat.ucsf.edu wrote: Or perhaps I'm confused about what the displayed results mean.  If a string has a literal \, does it get shown as \\? In the repr, yes. If you try printing the string, you'll see that it only contains one \. By the way,

Re: inserting \ in regular expressions

2011-10-26 Thread Dave Angel
On 10/26/2011 03:48 PM, Ross Boylan wrote: I want to replace every \ and (the two characters for backslash and double quotes) with a \ and the same character, i.e., \ - \\ - \ I have not been able to figure out how to do that. The documentation for re.sub says repl can be a string or a

Re: inserting \ in regular expressions

2011-10-26 Thread MRAB
On 26/10/2011 20:48, Ross Boylan wrote: I want to replace every \ and (the two characters for backslash and double quotes) with a \ and the same character, i.e., \ - \\ - \ I have not been able to figure out how to do that. The documentation for re.sub says repl can be a string or a