Remove Multiple words From String
14 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
hello,
i have a string, x= 'with all this stuff going down at the moment '
i want to remove words - with,all,this,at,the
and generate a new string so that i can feed only the important words into the RNNs.
x= 'stuff going down moment'
How can I do it?
Thank You
0 Commenti
Risposta accettata
Ameer Hamza
il 29 Ott 2020
Modificato: Ameer Hamza
il 29 Ott 2020
Try erase()
str = 'with all this stuff going down at the moment ';
words_to_remove = {'with ','all ','this ','at ','the '};
new_str = erase(str, words_to_remove)
Or if you have several words to remove, making it difficult to make a words_to_remove cell array manually
str = 'with all this stuff going down at the moment ';
words_to_remove = 'with,all,this,at,the';
words_to_remove = cellfun(@(x) {[x ' ']}, strsplit(words_to_remove, ','));
new_str = erase(str, words_to_remove)
2 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Deep Learning Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!