Explore Courses Blog Tutorials Interview Questions

1 Answer

0 votes
by (44.3k 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!

28.4k questions

29.7k answers


94.1k users

Browse Categories