[issue44773] case_insensitive kwarg in str.replace()

Serhiy Storchaka report at bugs.python.org
Fri Jul 30 16:05:07 EDT 2021


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

I concur with Raymond and Eric.

Note that in general case the problem is more complex that you may expect. First, some characters can match two characters (e.g. 'ß' matches 'SS'), and therefore indexes of characters are different in different cases. Second, you may want to take to account Unicode normalization, so 'й' will match 'й' (the former is a single character, the latter is two characters 'и'+'\u0306').

The re module will not help with solving the first problem. You should use the third-party regex package. For the second problem you can use unicodedata.normalize(),

----------
nosy: +serhiy.storchaka
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44773>
_______________________________________


More information about the Python-bugs-list mailing list