如何找出 NSString 中是否存在特定字符?
我有两个名为 Country 和 searchtext 的 NSString。我需要检查该国家/地区是否包含搜索文本。
例如:country=Iceland,searchtext=c,这里单词iceland包含字符“c”。
谢谢。
I have two NSStrings named country and searchtext. I need to check whether the country contains the searchtext.
Eg: country = Iceland and searchtext = c, here the word iceland contains the character 'c'.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个:
您的范围对象中还包含比赛的位置(地点)和长度(在本例中无趣,但在其他情况下可能很有趣)。请注意,
searchtext
不得为nil
。如果您只对匹配(而不是位置)感兴趣,您甚至可以将其压缩为Try this:
You also have the position (location) and length of your match (uninteresting in this case but might be interesting in others) in your range object. Note that
searchtext
must not benil
. If you are only interested in matching (and not the location) you can even condense this into很简单...试试这个
Very simple... try this