You're not not using the e
modifier in that PHP regex.
The following JavaScript should do the same as your PHP:
var url = 'http://www.amazon.com/dp/B002JCSBE4/ref=sr_1_1?ie=UTF8&s=tv&qid=1264738369&sr=1-1/';
var amazon_re = /http:\/\/[^>]*?amazon.(.*)\/([^>]*?ASIN|gp\/product|exec\/obidos\/tg\/detail\/-|[^>]*?dp)\/([0-9a-zA-Z]{10})[a-zA-Z0-9#\/\*\-\?\&\%\=\,\._;]*/i;
url = url.replace(amazon_re, 'http://www.amazon.$1/dp/$3/?tag=someone-20');
Brian McKenna
2010-01-29 04:48:14