I want to highlight some sentences in a text and I created this function:
function highlightReviewAux(content,text) {
return content.replace(new RegExp(`\\b${text}\\b`, "gi"), match => {
return '<span class="highlightText">' + match + '</span>';
});
It works except for this content ". [...] I booked this for a very special occasion, trusting that (the current title( “5 star The best 1 bed in Shoreditch” "
I think it's for the special characters. This is the error:
SyntaxError: Invalid regular expression: /\bNice wooden Bedroom floor showed poor care when decorating as white paint splatted all over it. [...] I booked this for a very special occasion, trusting that (the current title( “5 star The best 1 bed in Shoreditch” \b/: Unterminated group
Can you help me? I'm here for more than 2 hours and can't find the solution...