findAndReplaceDOMText: DOM find/replace utility
npm install heti-findandreplacedomtextForked from padolsey/findAndReplaceDOMText, add offset option to fix browsers which don't support regex lookbehind.
findAndReplaceDOMText searches for regular expression matches in a given DOM node and replaces or wraps each match with a node or piece of text that you can specify.
For example:
``html`
123 456 Hello
`js`
findAndReplaceDOMText(document.getElementById('t'), {
find: /Hello/,
wrap: 'em'
});
This would result in:
`html`
123 456 Hello
And it also works when matches are spread across multiple nodes! E.g.
`html`
123 456 Hello Goodbye
`js`
findAndReplaceDOMText(document.getElementById('t'), {
find: /Hello/,
wrap: 'em'
});
This would result in:
`html`
123 456 Hello Goodbye
The EM element has been added twice, to cover both portions of the match.
Grab the latest findAndReplaceDOMText.js (or npm install findandreplacedomtext) and include it as a