[프로그래머스] 모음 제거

당당·2023년 4월 22일
0

프로그래머스

목록 보기
36/245

https://school.programmers.co.kr/learn/courses/30/lessons/120849

📔문제

영어에선 a, e, i, o, u 다섯 가지 알파벳을 모음으로 분류합니다. 문자열 my_string이 매개변수로 주어질 때 모음을 제거한 문자열을 return하도록 solution 함수를 완성해주세요.


🚫제한사항

my_string은 소문자와 공백으로 이루어져 있습니다.
1 ≤ my_string의 길이 ≤ 1,000


📝입출력 예

my_stringresult
"bus""bs"
"nice to meet you""nc t mt y"

📝입출력 예 설명

입출력 예 #1

"bus"에서 모음 u를 제거한 "bs"를 return합니다.


입출력 예 #2

"nice to meet you"에서 모음 i, o, e, u를 모두 제거한 "nc t mt y"를 return합니다.


🧮알고리즘 분류

  • 문자열

📃소스 코드

class Solution {
    public String solution(String my_string) {
        String answer = "";
        String vowel="aeiou";
        
        answer=my_string.replaceAll("[aeiou]","");
        
        return answer;
    }
}

📰출력 결과


📂고찰

https://eggwhite0.tistory.com/40

해당 블로그를 보고 replaceAll()을 이용했다.

profile
MySQL DBA 신입 지원

0개의 댓글