Link to home
Start Free TrialLog in
Avatar of rae_rae
rae_raeFlag for United States of America

asked on

Help building javascript regular expression

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
ASKER CERTIFIED SOLUTION
Avatar of rae_rae
rae_rae
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial