Escaping regex unicode string in Python
问题 I have a user defined string. I want to use it in regex with small improvement: search by three apostrophes instead of one. For example, APOSTROPHES = re.escape('\'\u2019\u02bc') word = re.escape("п'ять") word = ''.join([s if s not in APOSTROPHES else '[%s]' % APOSTROPHES for s in word]) It works good for latin, but for unicode list comprehension gives the following string: "[\\'\\\\u2019\\\\u02bc]\xd0[\\'\\\\u2019\\\\u02bc]\xbf[\\'\\\\u2019\\\\u02bc][\\'\\\\u2019\\\\u02bc][\\'\\\\u2019\\\