HackerRank Python - Re.findall() & Re.finditer()




re.findall()
The expression re.findall() returns all the non-overlapping matches of patterns in a string as a list of strings.

re.finditer()
The expression re.finditer() returns an iterator yielding MatchObject instances over all non-overlapping matches for the re pattern in the string.



  1. # Enter your code here. Read input from STDIN. Print output to STDOUT
  2. import re
  3. vowels = 'aeiou'
  4. consonants = 'qwrtypsdfghjklzxcvbnm'
  5. match = re.findall(r'(?<=[' + consonants + '])([' + vowels + ']{2,})(?=[' + consonants + '])', input(), flags=re.I)
  6. print('\n'.join(match or ['-1']))
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]


donate a cup of tea :)


Join Our Facebook Group

Share this solution






codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube