Can I do a check to see if a string contains x word?

Posted by Sirius096 on Fri 01 Jun 2007 03:46 AM — 3 posts, 15,532 views.

#0
What I want to do, is store a whole line and run a check off that line to find out if it has 'x' word in it anywhere.

ie;
test (variable) = This is the line I want to check.

I want the if check to do this:
if (test <contains> "line") { <--- this is where I need the help
world.Note("blah");
}
else { (so if it doesnt contain 'line')
world.Note("not blah");
}
}

Heh... hope that is explained well enough. :/

-Siri
Amended on Fri 01 Jun 2007 03:58 AM by Sirius096
USA #1
Yes, to see if a string contains another string, use indexOf.

See:
http://www.w3schools.com/jsref/jsref_indexOf.asp

or google for "javascript indexOf" for plenty of other sites.
#2
Thanks :)