Back

Explore Courses Blog Tutorials Interview Questions

1 Answer

0 votes
by (44.4k points)

So normally, they would look like this and the last part of the URL is the ASIN:

http://www.amazon.com/Kindle-Wireless-Reading-Display-Generation/dp/B0015T963C

So, try this code:

var url = "http://www.amazon.com/Kindle-Wireless-Reading-Display-Generation/dp/B0015T963C";

var regex = RegExp("http://www.amazon.com/([\\w-]+/)?(dp|gp/product)/(\\w+/)?(\\w{10})");

m = url.match(regex);

if (m) { 

    alert("ASIN=" + m[4]);

}

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

Browse Categories

...