I\'m trying to detect an occurrence of a string within string. But the code below always returns \"null\". Obviously something went wrong, but since I\'m a newbie, I can\'t
The right tool for this job is not regex, but String.indexOf:
var str = '32:width: 900px;',
search = 'width',
isInString = !(str.indexOf(search) == -1);
// isInString will be a boolean. true in this case
Documentation: https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/String/indexOf