Python @ DjangoSpin

PyPro #53 Match an 'a' followed by 4 'b's in a String using RegEx

Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon
Reading Time: 1 minutes

Match an 'a' followed by 4 'b's in Python

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.


See also:

Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon

Leave a Reply