I created function for replace string with dictionary,
def tolower(text):
patterns = {
"\[(.*?)\]": (r"[\1-123]").lower()
}
for key in patterns:
text = re.sub(key, patterns[key], text)
return text
print tolower("[IMG]UPPER[/IMG]")
But I want python backreference \1 convert the string to lower after replace.
So, I'm expecting the result like this :
[img-123]UPPER[/img-123]
Can someone please tell me how it's working with replacing regex backreference?