jQuery - .replace

by Rafael Nepomuceno

HTML

<div id="before">
</div>
<br />
<div id="after">
</div>

JavaScript

var str = 'Xhellox, hxow AXre youx doiXXXng?'
$('#before').html(str);
str = str.replace('X', '_S_').replace('w','_R_');
$('#after').html(str);