MATLAB: Proper use of regexprep

MATLABstringstrings

I want to remove the consonants of a string, using regexprep. How can I modify the initial string s1 with a string s2?
s2 = regexprep(s1,'qwrtpsdfghjklzxcvbnmQWRTPSDFGHKLZXCVBNM','')

Best Answer

use the ^ operator. It should simply be,
s2 = regexprep(s1,'[^aeiou]','')
documentation explains it clearly here: https://de.mathworks.com/help/matlab/ref/regexprep.html