https://school.programmers.co.kr/learn/courses/30/lessons/120849
모음인 알파벳을 제외한 나머지 모든 알파벳을 answer에 +해준다.
#include <string>
#include <vector>
using namespace std;
string solution(string my_string) {
string answer = "";
for(auto& s : my_string)
{
if(s != 'a' && s != 'e' && s != 'i' && s != 'o' && s != 'u')
answer += s;
}
return answer;
}
#include <string>
#include <vector>
#include <regex>
using namespace std;
string solution(string my_string) {
string answer = "";
answer = regex_replace(my_string, regex("[aeiou]+"), "");
return answer;
}
regex를 사용하였다. my_string에서 모음을 다 ""로 치환하는 건데
regex("[aeiou]+")는 정규표현식인데 + 가 붙은건 aeiou중 1개만 있어도 치환하겠다는 것이다.
https://ansohxxn.github.io/cpp/chapter18-5/