var text = "this is a \n text \t.";Runtime:
text = text.replace(/ /g,'');
console.log(text);
thisestunthe character g defines the repetition of the search through the entire string. This regular expression removed white space but left line breaks and \t.
text.
If you want to remove all white space and not just the blank character, use \s like this:
text = text.replace(/\s/g,'');Execution:
thisisuntext.
Commentaires (0)
Laisser un commentaire
Connectez-vous pour commenter
Rejoignez la discussion et partagez vos connaissances avec la communauté
Chargement des commentaires...