I’m giving my users the ability to create their own MySQL queries. Don’t worry, I’m taking all the sql injection etc into account.
What I am wanting to do is validate the parentheses they use while creating their query…
So lets say they their query looks like this:
$string = '1 AND (2 OR 3) AND (4 AND (5 OR 6)';
See how they didn’t close the open parenthesis before the number 4? Is there any regex I could run on this to validate any open or closed parentheses that haven’t been added correctly?
I’ve been playing and searching everywhere but I have no idea how to make this work.
Thanks @Jayantha! Here’s the solution I found from clicking your link: