Regular expressions are used to match a given string by comparing it to a given pattern. Any given regular expression can match more lines, the longer the regular expression, the more lines it can match.
In my opinion, what you need cannot be done with regular expressions. You can write a program that deconstructs a regular expression and tries to guess the number of lines you could match. However, the construction of such a program is most likely not to be trivial.
For example, in your case, [a-zA-Z] will not only match a through z (and the same for the uppercase variant), but will also match any string containing these letters, which basically is any string, which you can imagine that contains at least one of these letters.
Adding ^ and $ anchors can reduce the number of calls, but again, you will still have more than 48, because sometimes you can also claim that {EmptyString}a{EmptyString} can also be matched ^a$ , which significantly increases the number of possible results.
source share