0

私はテキストを持っています:

SMS \r\n\t•    Map - locations of

•と次の最初の文字の間の空白をすべて削除するにはどうすればよいですか?

上記の例では、次のようになります。

SMS \r\n\t•Map - locations of
4

3 に答える 3

3

正規表現を使用すると、次のように実行できます。

var input = "SMS \r\n\t•    Map - locations of";

var regexPattern = @"(?<=•)\s+(?=\w)";
var cleanedInput = Regex.Replace(input, regexPattern, String.Empty);

これにより、•と最初の単語文字の間の空白が空の文字列に置き換えられます。

于 2012-05-11T15:12:30.223 に答える
1
string s = "SMS \r\n\t•    Map - locations of";
string[] temp = s.Split('•');
s = temp[0]+temp[1].TrimStart(' ');
于 2012-05-11T15:09:52.457 に答える
0

この正規表現を使用できます:

string toInsertBetween = string.Empty;
string toReplace = "SMS \r\n\t•    Map - locations of";
string res = Regex.Replace(toReplace, "•[ ]+([^ ])", "•" + toInsertBetween + "$1");
于 2012-05-11T15:19:07.250 に答える