![]() |
VOOZH | about |
Regular Expressions in Java allow developers to create patterns for matching strings. In this article, we will learn How to Check whether the Given Character String Starts with a Vowel.
Input: "Apple"
Output: Is a Vowel
Input: "Cart"
Output: Is not a Vowel
Let's delve into detailed examples to understand the application of regex for checking if a string starts with a vowel.
The string starts with a vowel.
-^(?i)[aeiou].* is the regular expression used for pattern matching:
The matches method is called on the inputString with the specified regular expression pattern.cIf the input string matches the pattern, it prints "The string starts with a vowel." Otherwise, it prints "The string does not start with a vowel."