program to match parenthesis order from a chunk of string