Browse - Programming Tips - How can I search for a string in another string?

Date: 2009jul1
Language: javaScript
Level: beginner

Q.  How can I search for a string in another string?

A.  You can use match() but if you don't need/want to look for a pattern,
use indexOf() like this:

function isThere(hay_stack, needle) { return hay_stack.indexOf(needle) >= 0; } // Example use: function isFirefox() { return isThere(navigator.userAgent, 'Firefox'); }