JSFiddle - React, Tailwind, and code Playground
HTML
How many <a href="http://www.example.com/42">roads</a> does a man walk down? 42. The quick brown fox jumps -4.2 m over the lazy 3dog4.
CSS
.foo { background-color: red; }
JavaScript
function autospan() {
var exp = /-?[\d.]+/g;
$('*:not(script, style, textarea)').contents().each(function() {
if (this.nodeType == Node.TEXT_NODE) {
var textNode = $(this);
var span = $('<span/>').text(this.nodeValue);
span.html(span.html().replace(exp, '<span class="foo">$&</span>'));
textNode.replaceWith(span);
}
});
}
$(autospan);