Specific Strings And NSScanner
Posted
by Garry
on Stack Overflow
See other posts from Stack Overflow
or by Garry
Published on 2010-05-24T22:32:23Z
Indexed on
2010/05/24
22:41 UTC
Read the original article
Hit count: 225
I need to determine whether a string (sourceString
) contains another string (queryString
) and if it does, at what offset.
I'm guessing that NSScanner might do the trick but I don't fully understand the documentation.
Let's say sourceString = @"What's the weather in London today?"
If I set queryString
to equal @"What's the weather"
, I'd like a method that would determine that, in this case, YES
(sourceString
does contain queryString
) and the offset is 0 (i.e. at the start of sourceString
).
Any suggestions?
© Stack Overflow or respective owner