Instantly share code, notes, and snippets.

View .js
highlightWords = (string, highlight) => {
let counter = 0;
let str = string;
let index = string.toLowerCase().indexOf(highlight.toLowerCase());
let result = [];
while(index > -1) {
result.push(<span key={counter++}>{str.slice(0, index)}</span>);
result.push(<mark key={counter++}>{str.slice(index, index + highlight.length)}</mark>);
str = str.slice(index + highlight.length);
View Migx-sample
Tabs:
[
{
"caption": "Tab Title",
"fields": [
{
"field": "title",
"caption": "Name"
},
{