Reputation: 3165
NSString *string = @"ABCDEFG";
NSString *FindString = @"DG";
BOOL result = [string containString(????):FindString];
I want a result if FindString is contained in string.
Because 'D' and 'G' is contained into string, above result is YES.
Is there a simple way to do this?
Upvotes: 0
Views: 83
Reputation: 1441
You can use NSRegularExpression which return ranges with matching expressions.
Upvotes: 0
Reputation: 8109
to check a subString you can use,
if (![string rangeOfString:FindString].length == 0)
{
// not found
}
else
{
// found
}
Upvotes: 0
Reputation: 28688
Something along the lines of..
NSCharacterSet *outerSet = [NSCharacterSet characterSetWithCharactersInString:@"ABCDEFG"];
NSCharacterSet *innerSet = [NSCharacterSet characterSetWithCharactersInString:@"DG"];
BOOL result = [outserSet isSupersetOfSet:innerSet];
Upvotes: 2