Q:

JavaScript regexp replace $0

I have this jQuery, and I would like to search for a string and replace it.  I know with php I can use $0, $1, $2 etc.  to get the matches. 
This is how I would do this via php $0 in this example would be replaced with the found plater and keep it's upper/lower casing:
preg_replace("/plater/i", "<span class='plater'>$0</span>", $input);

How can I do this in javascript?  When I try $0 it actually outputs $0 to the browser, and not what was found.  Here is what I currently have:
$(document).ready(function(){
    var html = $("body").html();
    $("body").html(html.replace(/plater/ig, "<span class='plater'>$0</span>"));
});

A:

Capture it with parenthesis and use $1 to refer to the "first" capture group. 
html.replace(/(plater)/ig, "<span class='plater'>$1</span>")

Guide to regex in several languages: http://www.regular-expressions.info/javascript.html

