I'd like to select the image source url from html code using javascript regexp. I'm using it to simplify using picasaweb images in other websites. I'm rather new at this, and I constructed a regex using http://www.regular-expressions.info/javascriptexample.html, and there it works like a charm, but not in my own script. Can somebody point me out the error in my script?
function addImage() {
var picasaDump=prompt("Copy the picasa link");
if (picasaDump!=null && picasaDump!="")
{
var regMatch = new RegExp("http:\/\/\S\.[jJ][pP][eE]?[gG]");
var imageLink = regMatch.exec(picasaDump);
if(imageLink == null) {
alert("Error, no images found");
} else if(imageLink.length > 1) {
alert("Error, multiple images fount");
} else {
further parsing...
}
}
}
EDIT: Some sample input
<a href="http://picasaweb.google.com/lh/photo/NHH78Y0WLPAAzIu0lzKlUA?feat=embedwebsite"><img src="http://lh3.ggpht.com/_ADW_3zOQhj8/TGgN4bXtfMI/AAAAAAAABCA/w6M-JKzNtBk/s144/DSC_2132.jpg" /></a>