I pretty new to python, so i have a dictionary with some keys in it, and a string. I have to replace the string if a pattern found in the dictionary exists in the string. bo
Don't use re for something so simple — just replace:
re
somedata = somedata.replace(key, 'newvalue')
That said, if you're constructing a regexp from something, use re.escape to escape special characters:
somedata=re.sub(re.escape(key), 'newvalue', somedata)