如何在UITextView或字符串中查找重复或相同单词的范围? [英] How to find the range of duplicate or same words in UITextView or from string?
问题描述
我正在努力在textview中查找任何单词的正词,在这里我需要找到单词首先说成的范围
I was working to find the rect of any word in textview ,where I need to find the range of the word first say as
NSRange textRange=[textview.text rangeofString:@"sabby"];
现在我在文本视图中说了三遍,现在我需要获取第二个的范围 不好意思的单词不是第一个...那么我该怎么做... 换句话来说,也是一样. 因为如果我使用上面的代码行,它将给我第一个到来的单词的范围 文本视图...
Now I am having sabby 3 times say in my textview.Now I need to get the range of the second sabby word not the first...Then how would I do this... And same for other words. Because if i go with above lines of code it gives me the range of first coming word in the textview...
谢谢n.干杯....
Thanks n Cheers.....
推荐答案
使用rangeOfString:options:range:
并将范围设置为在后续搜索中最后一次出现该字符串之后开始.
Use rangeOfString:options:range:
and set the range to start after the last occurence of the string in subsequent searches.
这篇关于如何在UITextView或字符串中查找重复或相同单词的范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!