iphone - Verify the existence of a word in an NSString -


I searched a bit, but this (probably very simple) question could not be answered.

I have an NSString, and I want to see if there is a word in it or not. Something like this:

  NSString * sentence = @ "Quick brown fox"; NSString * word = @ "quack"; If (word in sentence:)) {nslog (@ "yes it contains that word"); }  

Thanks.

The following should be done:

  NSString * sentence = @ " Quick Brown Fox "; NSString * word = @ "quack"; If ([sentence limitation opstring: word]. Location! = NSNotFound) {NSLog (@ "yes that includes that word"); }  

It uses the rangeOfString: to return a NSRange structure, which indicates the location of the word, If it can not be found, it will be equal to NSRange.location NSNotFound .


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -