Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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('(' + expStr + ')', '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));
Comment

PREVIOUS NEXT
Code Example
Javascript :: angular js 
Javascript :: sign javascript 
Javascript :: how to get checked and unchecked checkbox value in jquery 
Javascript :: redux reducer example 
Javascript :: react autocomplete 
Javascript :: react native firebase 
Javascript :: onmousedown 
Javascript :: props 
Javascript :: Query MongoDB - Node.js 
Javascript :: last value of array 
Javascript :: check items in array javascript 
Javascript :: what is palindrome 
Javascript :: rxjs operators 
Javascript :: vector icons react native 
Javascript :: new file shortcut vscode 
Javascript :: how to change background color in css and or js react 
Javascript :: timer javascript 
Javascript :: how to prevent previous radio button active react native 
Javascript :: node red push to array 
Javascript :: calculate init code hash nodejs 
Javascript :: js.l17 
Javascript :: client.connect is not a function node js mongodb 
Javascript :: flask server js return from folder 
Javascript :: knex muliple like query 
Javascript :: return <Text using if condition react native 
Javascript :: js 10.2 * 100 result of 10.199999 
Javascript :: play store version of react native app 
Javascript :: nodejs store selected dropdown in variable 
Javascript :: Map the peoples of Ray such as their first name comes first in the string in js 
Javascript :: mongoose save with data from req.body 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =