JSFiddle - React, Tailwind, and code Playground
HTML
<span>1d</span>
<span>2d</span>
<span>will expire in Unlimited</span>
<br />
<span>1d 2d will expire in Unlimited</span>
JavaScript
$(document).ready(function() {
function recursiveReplace(node) {
if (node.nodeType == 3) { // text node
node.nodeValue = node.nodeValue.replace("1d", "1 day");
node.nodeValue = node.nodeValue.replace("2d", "2 days");
node.nodeValue = node.nodeValue.replace("will expire in Unlimited", "will not expire");
return;
}
if (node.nodeType == 1) { // element
$(node).contents().each(function () {
recursiveReplace(this);
});
}
}
recursiveReplace(document.body);
});