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

Recommended Answers

All 2 Replies

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 :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.