javascript remove character from string
let str = 'Hello';
str = str.substring(1);
console.log(str);
/*
Output: ello
*/
var ret = "data-123".replace('data-','');
console.log(ret); //prints: 123mystring.replace(/r/g, '')
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:
- android studio react native plugins
- foreach async typescript
- jquery make readonly textbox
- react dark mode npm
- javascript get object from array where property equals
- textcontent js
- bootstrap 3 min max price range slider
- jquery enforce important
- javascript perfect square
- get radio button value javascript
- how to check if window size of browser s changed javascript
- javascript sum array of objects
- how could you implement javascript into java
- nodejs add element to array
- bcd full form in electronics
- Upload image via ajax (jquery)
- switch element array angular
- javascript change button text onclick
- onclick timer javascript
- angular injector.create example
- javascript continue
- is json valid with single quotes
- materialize for react
- lemon get node from id