JSFiddle - React, Tailwind, and code Playground
CSS
body { white-space: pre; }
JavaScript
function replace(s) {
return s.replace(/(?:[^/?=]|^)(\bX00[A-Z0-9]{7}\b)/gi, '<span class="context context_ident">$1<\/span>');
}
document.body.innerText = '';
document.body.innerText += replace("item :X00132BhJk") + '\n';
document.body.innerText += replace("www.domain.com/X00132BhJk") + '\n';
document.body.innerText += replace("www.domainsearch.com/search?ident=X00132BhJk") + '\n';
document.body.innerText += replace("X00132BhJk") + '\n';
document.body.innerText += replace("X00132BhJk") + '\n';