Finding a substring in a NSString object

2019-01-04 11:09发布

I have an NSString object and I want to make a substring from it, by locating a word.

For example, my string is: "The dog ate the cat", I want the program to locate the word "ate" and make a substring that will be "the cat".

Can someone help me out or give me an example?

Thanks,

Sagiftw

7条回答
干净又极端
2楼-- · 2019-01-04 11:55
-(BOOL)Contains:(NSString *)StrSearchTerm on:(NSString *)StrText
{
   return  [StrText rangeOfString:StrSearchTerm options:NSCaseInsensitiveSearch].location==NSNotFound?FALSE:TRUE;
}
查看更多
登录 后发表回答