remove two things from javascript string
var removeUselessWords = function(txt) {
var uselessWordsArray =
[
"a", "at", "be", "can", "cant", "could", "couldnt",
"do", "does", "how", "i", "in", "is", "many", "much", "of",
"on", "or", "should", "shouldnt", "so", "such", "the",
"them", "they", "to", "us", "we", "what", "who", "why",
"with", "wont", "would", "wouldnt", "you"
];
var expStr = uselessWordsArray.join("|");
return txt.replace(new RegExp('\\b(' + expStr + ')\\b', 'gi'), ' ')
.replace(/\s{2,}/g, ' ');
}
var str = "The person is going on a walk in the park. The person told us to do what we need to do in the park";
console.log(removeUselessWords(str));
Also in JavaScript:
- js return undefined on ReferenceError
- minecraft fps client that supports linux
- iife
- encriptar exadecimal con cryptojs
- javascript get width of a div
- console.log('qqqqqqqqqqqqqqqqqqqq'); jslint error how to fix
- js check if radio button is checked
- in select option how to make one default in angular
- React Components
- const in javascript
- angular viewchild set attribute
- how to find index of max number in js
- get length of array
- jquery extract number from string
- check if input is a number javascript
- count number of each element in array javascript
- what is node.js
- how to run a cloned react native project
- nodemon : The term 'nodemon' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + nodemon index
- js validate email
- javascript touppercase
- email collapsible section
- how to hide api key in react app
- react native vector icons