[M5_CSQ5] Construct an algorithm and write a python program python program to create
a regular expression to retrieve all words starting with vowels in each string. [CO2] [L2]
Test Cases are
case=1
case=2
input= An apple for a day input= Actions
keeps the doctor away louder than words.
I
output= An
output= Actions
apple
away
case=3
speak input= Everyone wants to
go to heaven, but nobody
wants to die.
output= Everyone
import re
regex = '^[aeiouAEIOU]*'
def check(S):
if(re.search(regex, S)):
print("Valid")
else:
print("Invalid")
if __name__ == '__main__' :
S = "anime"
check(S)
S = "hello"
check(S)
S = "kakashi"
check(S)
Comments
Leave a comment