On Jun 12, 4:11 am, anton <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I want to replace all occourences of " by \" in a string.
>
> But I want to leave all occourences of \" as they are.
>
> The following should happen:
>
> this I want " while I dont want this \"
>
> should be transformed to:
>
> this
On Jun 13, 6:23 pm, anton <[EMAIL PROTECTED]> wrote:
> John Machin lexicon.net> writes:
>
>
>
> > On Jun 12, 7:11 pm, anton <[EMAIL PROTECTED]> wrote:
> > > Hi,
>
> > > I want to replace all occourences of " by \" in a string.
>
> > > But I want to leave all occourences of \" as they are.
>
> > >
John Machin lexicon.net> writes:
>
> On Jun 12, 7:11 pm, anton <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I want to replace all occourences of " by \" in a string.
> >
> > But I want to leave all occourences of \" as they are.
> >
> > The following should happen:
> >
> > this I want " while I
anton wrote:
> I want to replace all occourences of " by \" in a string.
>
> But I want to leave all occourences of \" as they are.
>
> The following should happen:
>
> this I want " while I dont want this \"
>
> should be transformed to:
>
> this I want \" while I dont want this \"
>
>
John Machin <[EMAIL PROTECTED]> wrote:
> What you want is:
>
>>> import re
>>> text = r'frob this " avoid this \", OK?'
text
> 'frob this " avoid this \\", OK?'
>>> re.sub(r'(? frob this \\" avoid this \\", OK?'
>>>
>
Or you can do it without using regular expressions at all. Just replace
On Jun 12, 7:11 pm, anton <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I want to replace all occourences of " by \" in a string.
>
> But I want to leave all occourences of \" as they are.
>
> The following should happen:
>
> this I want " while I dont want this \"
>
> should be transformed to:
>
> this