I want to write a simple class to process Strings (may be very long strings up to 1mil characters in it). String will basically consists of two characters \"a\" and \"b\" that
Why do you need regular expression and split the string for this! You can simply loop through the string and count the number of a and bs. You need to keep two different counter, one for a and one for b. Using regular expression will be less efficient. There is no way you can get the result without traversing the string at least once. So use a simple loop to count a and b.
You can make one optimization in the loop. If anytime mod of countA - countB is greater than the number of remaining characters then a and b can never be equal. So you can break the loop then.
If the length of the string is odd then there is no need to count. Count of a and b can never be equal when total number of elements is odd.