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']))




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