For example if I have the following sentence:
a cat bit a dog on the butt before running away
If the 2 characters I want to use are 'a' and 'b' then I want to match up until the point where there are equal amounts of 'a' and 'b' like the following:
a cat bit a dog on the butt b
In the above case, the sentence has 5 a's and 3 b's. I want to much up to the point where I have 3 a's and 3 b's.
Thank you for the help.