How to use 'remove word from string javascript' in JavaScript

Every line of 'remove word from string javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
155function removeFirstWord(str, word) {
156 if (word === void 0) { word = ""; }
157 if (!word) {
158 word = getFirstWord(str);
159 }
160 var index = str.indexOf(word);
161 if (index == -1)
162 return str;
163 return str.substring(index + word.length);
164}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code


Related snippets