JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/ui-lightness/jquery-ui.css">
<div>
<div>
<div>The date is July 23</div>
<div>some other text</div>
<input value="123">
</div>
<div>The date is July 23, 1234</div>
<div id='clicker'>some other text</div>
</div>
CSS
span {
background: yellow;
}
JavaScript
var regex = /(\d+)/g,
replacement = '<span>$1</span>';
function replaceText(i,el) {
if (el.nodeType === 3) {
if (regex.test(el.data)) {
$(el).replaceWith(el.data.replace(regex, replacement));
}
} else {
$(el).contents().each( replaceText );
}
}
$('body').each( replaceText );