Replace Vowels with *
This program replaces vowels with *.
Problem Statement
Write a Java program to replace vowels in string with *.
Source Code
| 1 | public class RegexReplaceVowels { |
| 2 | public static void main(String[] args) { |
| 3 | System.out.println("Eduinq Regex Replace Vowels"); |
| 4 | String str="EduinqString"; |
| 5 | String result=str.replaceAll("[AEIOUaeiou]","*"); |
| 6 | System.out.println("After replacement: "+result); |
| 7 | } |
| 8 | } |
Program Output
Eduinq Regex Replace Vowels After replacement: *d**nqStr*ng
Explanation
Regex [AEIOUaeiou] matches vowels. - replaceAll() replaces vowels with *. - Together demonstrates vowel replacement. Conclusion: Shows how to replace vowels with *.