我正在使用一个Regex表达式,当有两个或更多个重复时,它会去除空格,只留下一个空格.
例如这一行
The cow jumped over the moon
Run Code Online (Sandbox Code Playgroud)
在某些情况下,有多个空格分隔单词会变成
The cow jumped over the moon
Run Code Online (Sandbox Code Playgroud)
Jef*_*ser 15
string cleanedString = Regex.Replace(input, @"\s+", " ");
Run Code Online (Sandbox Code Playgroud)