Task You are given a string. It consists of alphanumeric characters, spaces and characters (+, -). Your task is to find all the substrings of the original string containing two or more vowels. In addition, these substrings must be between consonants and contain only vowels.
Input format: one line of input containing a line.
Output format: print matched substrings in the order they appear on separate lines. If no match is found, type -1. A.
Input Example: rabcdeefgyYhFjkIoomnpOeorteeeeet
Output result:
ee
Ioo
Oeo
eeeee
The task above was taken from https://www.hackerrank.com/challenges/re-findall-re-finditer
The following code passes all test cases:
import re
sol = re.findall(r"[^aiueo]([aiueoAIUEO]{2,})(?=[^aiueo])", input())
if sol:
for s in sol:
print(s)
else:
print(-1)
The following fails.
import re
sol = re.findall(r"[^aiueo]([aiueoAIUEO]{2,})[^aiueo]", input())
if sol:
for s in sol:
print(s)
else:
print(-1)
- . , . , ?= , , [aiueoAIUEO]{2,}, , , , , .
?