alvinlindstam / grapheme

A python package for grapheme aware string handling
MIT License
106 stars 7 forks source link

Support for string.index #14

Open shantanu1227 opened 3 years ago

shantanu1227 commented 3 years ago

Example:

 ✨💫 Hello @Test , what's up?

Now I want to find index of @Test

alvinlindstam commented 3 years ago

Hi @shantanu1227, good suggestion. The more feature parity with strings, the better..

So in this scenario, I'd expect it to do what str.index does, but also check that there is grapheme boundaries before and after @Test, right? And would you want the index in terms of where it starts in the string or the grapheme index?

I think that this would basically be the same logic as the contains function, but with a different return value. I think that it would make sense to transform the containes function to an index or find function, and let the contains function build a boolean result based on calling the index/find one.

PRs welcome, I might get to it but no promises..