regex's
chibaA at TinterlogD.Tcom
chibaA at TinterlogD.Tcom
Sun May 14 22:28:13 EDT 2000
Hi,
For some reason, this segment of code doesn't do what it's supposed to
do... (it's supposed to take any \ " 's from inputString, and return
the same chacter preceeded with a \ to outputString). It works great
for the ' and " characters, but it just won't do the \. Any idea why?
def norm2mysqlinsert(inputString): # Used for insert and update in
MySQL
outputString = ''
p=re.compile('^[\\\'\"]$')
count = 0
for i in inputString:
if p.match(inputString[count]):
outputString = outputString + "\\" +
inputString[count]
else:
outputString = outputString +
inputString[count]
count = count + 1
return outputString
More information about the Python-list
mailing list