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:

So, try this code:

var url = "";

var regex = RegExp("[\\w-]+/)?(dp|gp/product)/(\\w+/)?(\\w{10})");

m = url.match(regex);

if (m) { 

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


Welcome to Intellipaat Community. Get your technical queries answered by top developers!

29.3k questions

30.6k answers


104k users

Browse Categories