JavaScript のテキストから余分な空白文字 (行に複数の空白文字) を削除するにはどうすればよいですか?
例えば
match the start using.
"match" と "the" の間のスペースを 1 つを除いてすべて削除するにはどうすればよいですか?
JavaScript のテキストから余分な空白文字 (行に複数の空白文字) を削除するにはどうすればよいですか?
例えば
match the start using.
"match" と "the" の間のスペースを 1 つを除いてすべて削除するにはどうすればよいですか?
myString = Regex.Replace(myString, @"\s+", " ");
あるいは:
RegexOptions options = RegexOptions.None;
Regex regex = new Regex(@"[ ]{2,}", options);
tempo = regex.Replace(tempo, @" ");
ただやって、
var str = "match the start using. Remove the extra space between match and the";
str = str.replace( /\s\s+/g, ' ' );
function RemoveExtraSpace(value)
{
return value.replace(/\s+/g,' ');
}
確かに、正規表現を使用して:
var str = "match the start using. Remove the extra space between match and the";
str = str.replace(/\s/g, ' ')