Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Obj-c

Idiom #39 Check if string contains a word

Set the boolean ok to true if the string word is contained in string s as a substring, or to false otherwise.

@import Foundation;
BOOL ok=[s containsString:word];

This check is case-sensitive, locale-unaware. There are similar messages for other cases
with Ada.Strings.Fixed;
use Ada.Strings.Fixed;
Ok : Boolean := Index (S, Word) > 0;

New implementation...
< >
programming-idioms.org