Help building javascript regular expression

rae_rae
rae_rae used Ask the Experts™
on
I have this code:
$('#' + divs[i]).filter(function()
{
	// Look for video divs
	var regex = '/\S+video/';
	if($(this).text().match(regex))
	{
		alert(id);
	}
});

Open in new window

The selector is getting the id of a div. If I alert($(this).text());, I get a string like my-video. I want to build a regular expression that matches any string containing the word video.

I tested my expression on a javascript regex testing website and it worked fine, but as soon as I use it in my script it doesn't find anything
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
I got it...

$('#' + divs[i]).filter(function()
{
	// Look for video divs
	if($(this).text().search('video') == 0)
	{
		alert(id);
	}
});

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial