title: Regex for checking if a string has mismatched parentheses?
body: <p>In a PHP script, what regex should I use to check for mismatched parentheses in a string?  Things that I want to allow include:</p>
  
  <ul>
  <li>This is (ok)</li>
  <li>This (is) (ok)</li>
  </ul>
  
  <p>Things I want to prevent:</p>
  
  <ul>
  <li>This is )bad(</li>
  <li>This is also (bad</li>
  <li>This is (bad (too)</li>
  </ul>
  
  <p>Thanks!</p>
  
  <p>Update:  You guys all rock.  Doing this with a regex seemed trickier than it should have, and these kinds of 2nd level answers are what makes stackoverflow beautiful.  Thanks for the links and the pseudocode.  I'm not sure who to give the answer to, so I apologize to everyone whose answers I can't accept.</p>