Last active
January 7, 2020 16:26
-
-
Save pombredanne/b90d0090bed9e9e976ba2ea454b02abd to your computer and use it in GitHub Desktop.
Unicode re split issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python | |
Python 3.6.8 (default, Dec 20 2019, 11:17:32) | |
[GCC 5.4.0 20160609] on linux | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> a='İrəli' | |
>>> len(a) | |
5 | |
>>> len(a.lower()) | |
6 | |
>>> import re | |
>>> re.split('\\W', a) | |
['İrəli'] | |
>>> re.split('\\W', a.lower()) | |
['i', 'rəli'] | |
>>> [len(x) for x in re.split('\\W', a.lower())] | |
[1, 4] | |
>>> sum(len(x.lower()) for x in a) | |
6 | |
>>> len(a.lower()) | |
6 | |
>>> list(a) | |
['İ', 'r', 'ə', 'l', 'i'] | |
>>> list(a.lower()) | |
['i', '̇', 'r', 'ə', 'l', 'i'] | |
>>> [x.isalpha() for x in a.lower()] | |
[True, False, True, True, True, True] |
Author
pombredanne
commented
Jan 7, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment