Exclamation marks series #11

Exclamation marks series #11: Replace all vowel to exclamation mark in the sentence

Description:

Replace all vowel to exclamation mark in the sentence. aeiouAEIOU is vowel.

Examples

replace("Hi!") === "H!!"
replace("!Hi! Hi!") === "!H!! H!!"
replace("aeiou") === "!!!!!"
replace("ABCDE") === "!BCD!"

Solution

public class Solution {
    public static String replace(final String s) {
            return s.replaceAll("[aeiouAEIOU]", "!");
    }
}
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments