title: strange string.IndexOf behavour
body: <p>I wrote the following snippet to get rid of excessive spaces in slabs of text</p>
  <pre><code>int index = text.IndexOf(&quot;  &quot;);
  while (index &gt; 0)
  {
      text = text.Replace(&quot;  &quot;, &quot; &quot;);
      index = text.IndexOf(&quot;  &quot;);
  }
  </code></pre>
  <p>Generally this works fine, albeit rather primative and possibly inefficient.</p>
  <h3>Problem</h3>
  <p>When the text contains &quot; - &quot; for some bizzare reason the indexOf returns a match!
  The Replace function doesn't remove anything and then it is stuck in a endless loop.</p>
  <p>Any ideas what is going on with the string.IndexOf?</p>