The following code matches 3 As and 4 Bs pattern in the given string as follows
Example
import re foo = 'AAABBBBBB' match = re.search(r'A{3}B{4}', foo) print match.group()
output
AAABBBB
The following code matches 3 As and 4 Bs pattern in the given string as follows
import re foo = 'AAABBBBBB' match = re.search(r'A{3}B{4}', foo) print match.group()
AAABBBB