remove character from string javascript
snippet in javascript

remove first char javascript

user7836

let str = 'Hello';
 
str = str.substring(1);
console.log(str);
 
/*
    Output: ello
*/

remove character from string javascript

user8758

//replaces the first occurence only.
string.replace('characterToReplace', '');
or 
// first parameter is regular expression and g is global prop, replaces all occurences.
string.replace('/regex/g','');

javascript remove character from string

user5673


var str = "Visit Microsoft!";

var res = str.replace("Microsoft", "W3Schools");
 

remove character from string python

user1452

string = 'Hello WorldR'
# Lets say for instance you want to remove the R to display
# Hello World

print(string[:-1]) 
"""
The [:-<number of chars>] to remove from string starting from
right to left
"""

delate char betwen index js

user2209

// First find the substring of the string to replace, then replace the first occurrence of that string with the empty string.

S = S.replace(S.substring(bindex, eindex), "");

//Another way is to convert the string to an array, splice out the unwanted part and convert to string again.

var result = S.split("");
result.splice(bindex, eindex - bindex);
S = result.join("");

remove two things from javascript string

user6410

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));