data = re.sub(u"\u102F*\u102D", u"\u102D\\2\u102F", data)
data = re.sub(u"\u1031*\u103B", u"\u103B\\2\u1031", data)
data = re.sub(u"\u1001*\u102C", u"\u1001\\2\u102B", data)
data = re.sub(u"\u1002*\u102C", u"\u1001\\2\u102B", data)
data = re.sub(u"\u1004*\u102C", u"\u1001\\2\u102B", data)
data = re.sub(u"\u1007*\u102C", u"\u1001\\2\u102B", data)
data = re.sub(u"\u1012*\u102C", u"\u1001\\2\u102B", data)
data = re.sub(u"\u1013*\u102C", u"\u1001\\2\u102B", data)
data = re.sub(u"\u1014*\u102C", u"\u1001\\2\u102B", data)
data = re.sub(u"\u1015*\u102C", u"\u1001\\2\u102B", data)
data = re.sub(u"\u1016*\u102C", u"\u1001\\2\u102B", data)
data = re.sub(u"\u1017*\u102C", u"\u1001\\2\u102B", data)
data = re.sub(u"\u1018*\u102C", u"\u1001\\2\u102B", data)
I am writing a Unicode conversion tool, but am a bit stuck at regex. As an example between these to characters U+1001 and U+102C there might one or two other characters stuck. I tried backreferencing with \2, but got throne the following error:
raise error, "invalid group reference"
sre_constants.error: invalid group reference
Also if I wanted to swap position of two Unicode Characters using regex how would I do it? If I have AB, AC, AD and I wish to change that to BA, CA and DA? Thanks.