This problem is matching brackets, but with regular expression.
Given a set of parenthesis, if they are balanced, print it. If not, leave the output empty.
A line with a set of opening and closing parentheses. There will be at most 200 parenthesis.
If the entire set of parentheses is balanced, the output should contain the entire set of parentheses. Otherwise, the output should be empty.
Input | Output |
---|---|
(()) | (()) |
Input | Output |
---|---|
()() | ()() |