title: How to ignore whitespace and punctuation?
body: <p>I wrote a palindrome checker function and it works for the most part, but if the whitespace or punctuation isn't in the middle of the string it says it isn't a palindrome. </p>
  
  <p>i.e </p>
  
  <p>First test:</p>
  
  <pre><code>Enter string to test for palindrome:
  
  hannah
  
  string is a palindrome.
  </code></pre>
  
  <p>Second test:</p>
  
  <pre><code>Enter string to test for palindrome:
  
  han nah
  
  string is a palindrome.
  </code></pre>
  
  <p>Third test:</p>
  
  <pre><code>Enter string to test for palindrome:
  
  hann.ah
  
  string is not a palindrome.
  </code></pre>
  
  <p>Fourth test:</p>
  
  <pre><code>Enter string to test for palindrome:
  
  han.nah
  
  string is a palindrome.
  </code></pre>
  
  <p>I was wondering if there is a way to ignore the whitespace and punctuation all together so that <code>h.annah</code> or <code>hann ah</code> would be considered a palindrom?</p>
  
  <p>Here's my code:</p>
  
  <pre><code>void isPalindrome (string s){  
      if(equal(s.begin(), s.begin() + s.size()/2, s.rbegin()) )
          cout &lt;&lt; "string is a palindrome. " &lt;&lt; endl;
      else
          cout &lt;&lt; "string is not a palindrome. " &lt;&lt; endl;
  }
  
  int main(){
      string test1;
      cout &lt;&lt; "Enter string to test for palindrome: " &lt;&lt; endl;
      getline(cin, test1);
  
      isPalindrome(test1);
  
      string test2;
      cout &lt;&lt; "Enter string to test for palindrome: " &lt;&lt; endl;
      getline(cin, test2);
  
      isPalindrome(test2);
  
      string test3;
      cout &lt;&lt; "Enter string to test for palindrome: " &lt;&lt; endl;
      getline(cin, test3);
  
      isPalindrome(test3);
  
      return 0;
  }   
  </code></pre>