I am trying to highlight all text that match any word of my search text.
Assume search text all text
My query return all record which text contains any of word of above text (Same as text search in MSSQL)
Now i need to highlight all matches with any word in search. My current code can highlight only full text.
My Current Code:
getHighlightedText(text, higlight) {
let parts = text.split(new RegExp(`(${higlight})`, 'gi'));
return <span> { parts.map((part, i) =>
<span key={i} style={part.toLowerCase() === higlight.toLowerCase() ? { color: '#93C74B' } : {} }>{part}</span>)
} </span>;
}
Thanks in advance.