This project has moved and is read-only. For the latest updates, please go here.

Why are two spaces not replaced with one in my ReplaceText() code?

Jan 3, 2014 at 5:35 PM
Edited Jan 3, 2014 at 5:49 PM
Why are two spaces not being replaced with one with my code?

I have this code, which should find all sentences with two spaces between them, and remove one of the spaces so they have the preferred single space between sentences:
const int firstCapPos = 65;
const int lastCapPos = 90;
const int firstLowerPos = 97;
const int lastLowerPos = 122;

    . . .

// This should change sentences like this: "I scream.  You scream.  We all scream of ice cream." ...to this: "I scream. You scream. We all scream of ice cream."
private void SnuggifyLooseyGooseySentenceEndings(string filename)
{
    using (DocX document = DocX.Load(filename))
    {
        for (int i = firstCapPos; i <= lastCapPos; i++)
        {
            char c = (char)i;
            string originalStr = string.Format(".  {0}", c);
            string newStr = string.Format(". {0}", c);
            document.ReplaceText(originalStr, newStr);
        }
        for (int i = firstLowerPos; i <= lastLowerPos; i++)
        {
            char c = (char)i;
            string originalStr = string.Format(".  {0}", c);
            string newStr = string.Format(". {0}", c);
            document.ReplaceText(originalStr, newStr);
        }
        document.Save();
    }
}
Why is it not working?

UPDATE: Never mind, it works now (http://stackoverflow.com/questions/20909150/why-is-this-simple-text-replacement-code-not-working/20909277?noredirect=1#20909561)