I would like a regex that returns all of the A’s and all of the B’s in a string like ‘AABCTA’ with similar characters grouped together in the result i.e. [AAA, BB]. Note that there may be thousands of repeated letters.
This works for just the A’s:
re.findall(r'[A]','AABCTBA') ['A', 'A', 'A']
['A', 'A', 'B', 'A']
['A' 'A' 'A', 'B'].
What I ultimately want is a count of the letters so if there is a different way to get the letter count using regex I’d love to see that.