A: 

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
A: 

The /e modifier is used to execute code. In Javascript, you can do so by passing a function.

For example:

preg_replace("/(<\/?)(\w+)([^>]*>)/e", 
         "'\\1'.strtoupper('\\2').'\\3'", 
         $html_body);

becomes

html_body.replace(/(<\/?)(\w+)([^>]*>)/, function(s, x1, x2, x3) {
  return x1 + x2.toUpperCase() + x3;
});

in Javascript. (But again, you did not using the /e flag in that PHP code.)

KennyTM