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>"));
});