var text = "これは\nテキスト\tです。Runtime:
text = text.replace(/ /g,'');
console.log(テキスト);
thisestun文字 g は、文字列全体に対する検索の繰り返しを定義します。この正規表現は空白を削除しましたが、改行と \t.
text.
空白文字だけでなく、すべての空白を削除する場合は、\s のように:
text = text.replace(/\s/g,'');Execution:
thisisuntext.
var text = "これは\nテキスト\tです。Runtime:
text = text.replace(/ /g,'');
console.log(テキスト);
thisestun文字 g は、文字列全体に対する検索の繰り返しを定義します。この正規表現は空白を削除しましたが、改行と \t.
text.
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...