To be clear, this solution works perfectly if it's guaranteed that `testString` *only* contains parentheses. Otherwise you have to strip all the non-parentheses out first
-
-
Show this thread
-
If you don't strip non-parentheses out first, there are a few failure cases: (abc\) - returns false, should be true [abc)(] - returns true, should be false
Show this thread
End of conversation
New conversation -
-
-
this is how JS programmers check for valid JSON
-
try { eval(json) } ...
- 2 more replies
New conversation -
-
-
Thanks i hate it
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
the regex could also be invalid for other reasons ;-)
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
wouldn't work if there's a "\)" combination, i think
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
/cc
@ForbesLindesay - wish I'd thought of that in my interview.Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Regexes are super obscure. I usually just do: isBalanced = (t) => CSS.supports(`($${t}) or (not ())`)
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.