A
anton
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 I want \" while I dont want this \"
and NOT:
this I want \" while I dont want this \\"
I tried even the (?<=...) construction but here I get an unbalanced paranthesis
error.
It seems tha re is not able to do the job due to parsing/compiling problems
for this sort of strings.
Have you any idea??
Anton
Example: --------------------
import re
re.findall("[^\\]\"","this I want \" while I dont want this \\\" ")
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python25\lib\re.py", line 175, in findall
return _compile(pattern, flags).findall(string)
File "C:\Python25\lib\re.py", line 241, in _compile
raise error, v # invalid expression
error: unexpected end of regular expression
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 \"
and NOT:
this I want \" while I dont want this \\"
I tried even the (?<=...) construction but here I get an unbalanced paranthesis
error.
It seems tha re is not able to do the job due to parsing/compiling problems
for this sort of strings.
Have you any idea??
Anton
Example: --------------------
import re
re.findall("[^\\]\"","this I want \" while I dont want this \\\" ")
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python25\lib\re.py", line 175, in findall
return _compile(pattern, flags).findall(string)
File "C:\Python25\lib\re.py", line 241, in _compile
raise error, v # invalid expression
error: unexpected end of regular expression