re.finditer()<\/a><\/sub><\/p>\n\n\n\nThe expression re.finditer()<\/em> returns an iterator yielding MatchObject<\/code> instances over all non-overlapping matches for the re<\/em> pattern in the string.<\/p>\n\n\n\nCode<\/strong><\/p>\n\n\n\n>>> import re\n>>> re.finditer(r'\\w','http:\/\/www.hackerrank.com\/')\n<callable-iterator object at 0x0266C790>\n>>> map(lambda x: x.group(),re.finditer(r'\\w','http:\/\/www.hackerrank.com\/'))\n['h', 't', 't', 'p', 'w', 'w', 'w', 'h', 'a', 'c', 'k', 'e', 'r', 'r', 'a', 'n', 'k', 'c', 'o', 'm']<\/code><\/pre>\n\n\n\n<\/span>Task<\/strong><\/span><\/h2>\n\n\n\nYou are given a string S<\/em><\/strong>. It consists of alphanumeric characters, spaces and symbols(+<\/code>,-<\/code>).
Your task is to find all the substrings of S<\/strong><\/em> that contains 2<\/strong> or more vowels.
Also, these substrings must lie in between 2<\/strong> consonants and should contain vowels only.<\/p>\n\n\n\n<\/span>Input Format<\/strong><\/span><\/h2>\n\n\n\nA single line of input containing string S<\/strong><\/em>.<\/p>\n\n\n\n<\/span>Constraints<\/strong><\/span><\/h2>\n\n\n\n- 0 < len<\/em>(S<\/em>) < 100<\/strong><\/li><\/ul>\n\n\n\n
<\/span>Output Format<\/strong><\/span><\/h2>\n\n\n\nPrint the matched substrings in their order of occurrence on separate lines.
If no match is found, print -1<\/code>.<\/p>\n\n\n\nSample Input<\/strong><\/p>\n\n\n\nrabcdeefgyYhFjkIoomnpOeorteeeeet<\/code><\/pre>\n\n\n\nSample Output<\/strong><\/p>\n\n\n\nee\nIoo\nOeo\neeeee<\/code><\/pre>\n\n\n\nExplanation<\/strong><\/p>\n\n\n\nee<\/strong> is located between consonant d<\/em><\/strong> and f<\/strong><\/em>.
Ioo<\/strong> is located between consonant k<\/strong><\/em> and m<\/em><\/strong>.
Oeo<\/strong> is located between consonant p<\/em><\/strong> and r<\/strong><\/em>.
eeeee<\/strong> is located between consonant t<\/strong><\/em> and t<\/strong><\/em>.<\/p>\n\n\n\n<\/span>Solution – Re.findall() & Re.finditer() in Python<\/strong><\/span><\/h2>\n\n\n\n# Enter your code here. Read input from STDIN. Print output to STDOUT\nimport re\n\nvowels = 'aeiou'\nconsonants = 'qwrtypsdfghjklzxcvbnm'\nmatch = re.findall(r'(?<=[' + consonants + '])([' + vowels + ']{2,})(?=[' + consonants + '])', input(), flags=re.I)\nprint('\\n'.join(match or ['-1']))<\/pre>\n\n\n\n