Valid Parentheses

1
2
3
4
5
function validParentheses(parens){
var re = /\(\)/;
while (re.test(parens)) parens = parens.replace(re, "");
return !parens;
}