0

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 ? :/

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Karas87
0

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 "\").

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.