Assuming I have an Amazon product URL like so
http://www.amazon.com/Kindle-Wireless-Reading-Display-Generation/dp/B0015T963C/ref=amb_link_86123711_2?pf_rd_m=ATVP
This may be a simplistic approach, but I have yet to find an error in it using any of the URL's provided in this thread that people say is an issue.
Simply, I take the URL, split it on the "/" to get the discrete parts. Then loop through the contents of the array and bounce them off of the regex. In my case the variable i represents an object that has a property called RawURL to contain the raw url that I am working with and a property called VendorSKU that I am populating.
try
{
string[] urlParts = i.RawURL.Split('/');
Regex regex = new Regex(@"^[A-Z0-9]{10}");
foreach (string part in urlParts)
{
Match m = regex.Match(part);
if (m.Success)
{
i.VendorSKU = m.Value;
}
}
}
catch (Exception) { }
So far, this has worked perfectly.