If you really want to do this kind of script-checker, you really need to learn regex. That's the only way you're really going to have any luck with anything more than basic things, such as the number of parentheses/brackets.
I can't help you with that, though... I've not really learned it. Others here have a good handle on it if you have questions, though.