Program to check if the string starts with vowel or not using Regex


The task is to check whether the given string starts with vowel using regex expression.

check if the string starts with vowel


import re 
def check_str(ip_str): 
# Regular expression for vowel
    re_exp = '^[aeiouAEIOU][A-Za-z0-9_]*'
    if(, ip_str)):  
        print("The string starts with vowel!")  
        print("The string does not start with vowel!")  
ip_str = input("Enter the string: ")


check if the string starts with vowel Output


In the above python code we have created a regex expression of string starting with vowel and passed the expression and sing in search() method. If the pattern is found, the output “The string starts with vowel!” is printed else “The string does not starts with vowel!” is printed.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.