How strict do you want the checking to be? The initial algorithm accepts (1),(2, 3)
as valid input, as well as 1,2,3))))))
etc.
You might want to consider changing your regex to make it more strict, as there are a lot more than just your example input (1, 2, 3)
that gets excepted.