Replace two hyphens with an em dash
by Zane Ng
HTML
<div class="text_div">
<p>This--I mean this--is a test.</p>
</div>
JavaScript
$('p').contents().filter(function() {
return this.nodeType == 3
}).each(function() {
this.textContent = this.textContent.replace(/--/g, '—');
});