Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Simple remove word function
- * @param {string} string The string where the words will be removed.
- * @param {string|array} toRemove A single word or an array of words to remove
- */
- function removeWord(string, toRemove) {
- return (Array.isArray(toRemove)) ?
- string.replace(new RegExp('(' + toRemove.join(')|(') + ')', 'g'), '') :
- string.split(' ').filter(word => word !== toRemove).join(' ')
- }
Add Comment
Please, Sign In to add comment