I am trying to make separate counts of open and closed parentheses in a JavaScript string. How can I write the regex to accomplish this?
Here is what I have so far, which is throwing errors:
($scope.somevariable.match(new RegExp("\(", "g")) || []).length
and:
($scope.somevariable.match(new RegExp("\)", "g")) || []).length
The results of google searches on this topic all have very complicated expressions. This question is about a very simple example of just counting the number of (
and )
separately.
I am using AngularJS.