Browse - programming tips - javascript search a string for another stringDate: 2009jul1 Language: javaScript 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'); }
Add a commentSign in to add a comment | Advertisements:
|