Compare 2 string

Hello I would like to compare two string to each other.I would like that there is color in text.

String text="My color is black";
String color="black";

How can I do that?
Thanks.

Tried if(text.indexOf(color) > 0)?

http://forum.arduino.cc/index.php?topic=8647.0

Old-fashioned here :wink: If you don't use String (capital S) but character arrays

char text[] = "My color is black";
char color[] = "black";

if(strstr(text, color) != NULL)
{
  // match
}
else
{
  // no match
}

man strstr

JaBa:
Tried if(text.indexOf(color) > 0)?

inString function. - Exhibition - Arduino Forum

That would not work if the text is "black is my favorite color", it would return 0 which you exclude with strictly greater. The function returns -1 if not found, that is what needs to be tested.

Obviously our recommendation would be to not use Strings with a capital S and go lower level with char arrays.