I am trying to match URLs with a tested Regex expression but when I use JavaScript to evaluate it returns false.
Here is my code:
var $regex = new RegExp("<a\shref=\"(\#\d+|(https?|ftp):\/\/[-a-z0-9+&@#\/%?=~_|!:,.;\\(\\)]+)\"(\stitle=\"[^\"<>]+\")?\s?>|<\/a>"); var $test = new Array(); $test[0] = '<a href="http://www.nytimes.com/imagepages/2010/09/02/us/HURRICANE.html">'; $test[1] = '<a href="http://www.msnbc.msn.com/id/38877306/ns/weather/%29;">'; $test[2] = '<a href="http://www.msnbc.msn.com/id/38927104" title="dd" alt="dd">'; for(var i = 0; i < $test.length; i++) { console.log($test[i]); console.log($regex.test($test[i])); } Anyone have any idea what is going on?