I have a string like:
If ({{SQL}}.Employee.Title starts with 'Production')
and (substring of {{SQL}}.Employee.Title from '27' for '2' is not '30')
and ({{SQL}}.Employee.HireDate is greater than or equal to '2000-01-01 00:00:00.000')
then Pull {{SQL}}.Title, {{SQL}}.HireDate from Employee
From this expression, I want to find out whether round brackets are properly balanced or not in Java language.
One way is to create a counter variable which will be incremented as soon as I find out the opening bracket and decrement it when closing bracket is encountered. Based on the result, I can decide the result.
But this is not going to help for string like () i.e. not having any alpha numeric character between brackets.
Is there any way in which I can determine whether round brackets are balanced and there should be alpha numeric characters between these brackets. In case brackets are empty i.e. no character between opening and closing brackets, it should throw an error.