Skip to content

Instantly share code, notes, and snippets.

@pombredanne
Created November 10, 2019 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pombredanne/7c97c3e437c80f3e858db5fe836a0c95 to your computer and use it in GitHub Desktop.
Save pombredanne/7c97c3e437c80f3e858db5fe836a0c95 to your computer and use it in GitHub Desktop.
>>> len('İ')
1
>>> len('İ'.lower())
2
@pombredanne
Copy link
Author

pombredanne commented Nov 10, 2019

>>> import re
>>> pat = '[^_\\W]+\\+?[^_\\W]*'
>>> q = 'İ mit license'
>>> list(pat.findall(q.lower()))[0]=='i'
True
>>> list(pat.finditer(q.lower()))[0]=='i'
False

@pombredanne
Copy link
Author

>>> pat=re.compile('[^_\\W]+\\+?[^_\\W]*')
>>> q='İ'
>>> found = [m.lower() for m in pat.findall(q)]
>>> lowered=[m for m in pat.findall(q.lower())]
>>> found == lowered
False
>>> found 
['i̇']
>>> lowered
['i']
>>> lowered == ['i']
True
>>> found == ['i']
False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment