I have a string (i.e If you ask the makers of paper products, they will tell you that to be Agile you need to write ...) and the search terms (i.e ['makers', 'to be Agile']).
I expect this result If you ask the <strong>makers</strong> of paper products, they will tell you that <strong>to</strong> <strong>be</strong> <strong>Agile</strong> you need to write ...
I implement that with this method but sometimes doesn't work correctly.
private emphasize(text: string, highlights: string[]) {
return highlights
.filter(highlight => text.includes(highlight))
.map(highlight => highlight.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'))
.reduce((txt, highlight) => {
return txt.replace(new RegExp(highlight, 'gi'), '<strong>$&</strong>');
}, text);
}