Regex for accent insensitive replacement in python
问题 In Python 3, I'd like to be able to use re.sub() in an "accent-insensitive" way, as we can do with the re.I flag for case-insensitive substitution. Could be something like a re.IGNOREACCENTS flag: original_text = "¿It's 80°C, I'm drinking a café in a cafe with Chloë。" accent_regex = r'a café' re.sub(accent_regex, 'X', original_text, flags=re.IGNOREACCENTS) This would lead to "¿It's 80°C, I'm drinking X in X with Chloë。" (note that there's still an accent on "Chloë") instead of "¿It's 80°C, I