我试图找到一个函数来删除多余的连续空格,除非空格在字符串文字内,用单引号或双引号表示。
string source = "sqlcmd.exe -Q \"LEAVE SQL TEXT HERE UNCHANGED BECAUSE IT'S IN A DBL QUOTE BLOCK\"";
string expected = "sqlcmd.exe -Q \"LEAVE SQL TEXT HERE UNCHANGED BECAUSE IT'S IN A DBL QUOTE BLOCK\"";
string actual = StringExtensions.RemoveRedundantSpaces(source);
Assert.AreEqual(expected, actual);