Proper use of regexprep
Show older comments
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','')
2 Comments
Guillaume
on 22 Jan 2018
I don't understand the question. Your code already remove the consonants (assuming basic latin alphabet only). What more do you want?
per isakson
on 17 Dec 2018
Your statement is lacking the square brackets. Try
s2 = regexprep(s1,'[qwrtpsdfghjklzxcvbnmQWRTPSDFGHKLZXCVBNM]','')
Accepted Answer
More Answers (1)
the cyclist
on 22 Jan 2018
Edited: the cyclist
on 22 Jan 2018
Can you just do
s1 = s2;
after that? Or just
s1 = regexprep(s1,'qwrtpsdfghjklzxcvbnmQWRTPSDFGHKLZXCVBNM','');
directly, eliminating creating the intermediate variable s2?
Categories
Find more on Characters and Strings in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!