Hi everybody, I have the following URL to grab:
http://www.mysite.com/profile.php5?id=43534&mode=photo&pic_id=3453432#pic

I need the 2 ids.
But it doesn't seem to work.

var url = "http://www.mysite.com/profile.php5?id=43534&mode=photo&pic_id=3453432#pic";
var exp = new RegExp("^http:\/\/w?w?w?\.?mysite\.com\/profile\.php.?\?id=(\d+)&mode=photo&pic_id=(\d+).*?$");

if (exp.test(url)) {
var found = exp.exec(url);
alert("found0: "+found[0]+" found1: "+found[1]);
}

What am I doing wrong ? :/

In Java regex, there is no reason to escape "/", and, if you do need to escape something, then you also need to escape the escape as the escape character also escapes characters in String, in general (i.e. "\\" every place you need a "\").

In Java regex, there is no reason to escape "/", and, if you do need to escape something, then you also need to escape the escape as the escape character also escapes characters in String, in general (i.e. "\\" every place you need a "\").

Thanks, it worked like a charm, I didn't know :)

This question has already been answered. Start a new discussion instead.