Skip to content

Instantly share code, notes, and snippets.

@tyv
Created November 25, 2015 11:52
Show Gist options
  • Save tyv/481fc5015111e45e74f2 to your computer and use it in GitHub Desktop.
Save tyv/481fc5015111e45e74f2 to your computer and use it in GitHub Desktop.
if (keys.length) {
const re = new RegExp(keys.join('|'), 'g')
const newContent = []
const keysInText = content.match(re)
content
.split(re)
.forEach((substr, i, arr) => {
newContent.push(substr)
if (i < arr.length - 1) newContent.push(<strong>{keysInText[i]}</strong>)
})
content = newContent
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment