In a PHP script, what regex should I use to check for mismatched parentheses in a string? Things that I want to allow include:
- This is (ok)
- This (is) (ok)
Things I want to prevent:
- This is )bad(
- This is also (bad
- This is (bad (too)
Thanks!
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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…