To answer your question, it's to give the appearance of fairness. It's the same reason Russia holds elections.
Counting capturing groups is a solved problem - http://stackoverflow.com/questions/16046620/regex-to-count-t...
You can get the index of the match via the .exec function. It returns an array. The first element is the match, and then an element for each capturing group. You'd need to keep track of how many sub-capturing groups…
To answer your question, it's to give the appearance of fairness. It's the same reason Russia holds elections.
Counting capturing groups is a solved problem - http://stackoverflow.com/questions/16046620/regex-to-count-t...
You can get the index of the match via the .exec function. It returns an array. The first element is the match, and then an element for each capturing group. You'd need to keep track of how many sub-capturing groups…