Reading Time: 1 minutes
Match an 'a' followed by 4 'b's in Python
Match an 'a' followed by 4 'b's: Write a Regular Expression in Python which matches an 'a' followed by 4 'b's in a string.
Match an 'a' followed by 4 'b's
import re sourceString = 'aabb abab abbbbbb' print( re.findall('ab{4}', sourceString) ) # ['abbbb']
To learn more about Regular Expressions in Python, click here.