C++ function to remove parenthesis from string doesn't catch them all
<p>I wrote a function in c++ to remove parenthesis from a string, but it doesn't always catch them all for some reason that I'm sure is really simple.</p>

<pre><code>string sanitize(string word)
{
int i = 0;

while(i &lt; word.size())
{
    if(word[i] == '(' || word[i] == ')')
    {
        word.erase(i,1);
    }
    i++;
}
return word;
}
</code></pre>

<p>Sample result:</p>

<p>Input:  ((3)8)8)8)8))7</p>

<p>Output: (38888)7</p>

<p>Why is this?  I can get around the problem by calling the function on the output (so running the string through twice), but that is clearly not "good" programming.  Thanks!</p>
