Попробуй так
Regex.Replace(str, "[ ]+", " ")
Второй вариант для твоих начальных знаний
public class Word
{
public Word(int index)
{
Index = index;
}
public int Index { get; set; }
}
var text = "Мама мыла папу + big space!";
const char findWord = ' ';
var wordsDictionary = new List<List<Word>>();
var count = 0;
var words = new List<Word>();
for (var index = 0; index < text.Length; index++)
{
var word = text[index];
if (word == findWord)
{
words.Add(new Word(index));
count++;
}
else if(count > 0 && word != findWord)
{
wordsDictionary.Add(new List<Word>(words));
words.Clear();
count = 0;
}
}
wordsDictionary.Reverse();
foreach (var lettersList in wordsDictionary)
{
lettersList.Reverse();
text = lettersList.Skip(1).Aggregate(text, (current, letter) => current.Remove(letter.Index, 1));
}
MessageBox.Show(text);