In this HackerRank Re.findall() & Re.finditer() problem solution You are given a string S. It consists of alphanumeric characters, spaces and symbols(+,-). Your task is to find all the substrings of S that contain 2 or more vowels. Also, these substrings must lie in between 2 consonants and should contain vowels only.

HackerRank Re.findall() & Re.finditer() in python problem solution

HackerRank Re.findall() & Re.finditer() in python problem solution

import re

s = raw_input()

r = re.compile('[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]([aeiouAEIOU]{2,})(?=[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ])')

ar = re.findall(r, s)

if len(ar) > 0:
    for i in ar:
        print i
else:
    print -1