all the substrings of a given string S
Afficher commentaires plus anciens
Howdy everyone, I need to select all the substrings available from a given string S. By substring I mean any S(i:j), with j <= length(S) and i<=j. I wrote the following working code:
if true
voc{1}='';
cont=2;
for i=1:length(string)
for j=i:length(string)
voc{cont}=string(i:j);
cont=cont+1;
end
end
voc=unique(voc);
end
The variable voc contains all the substrings plus the element '' in the first position. I would need something faster than this. Any suggestion is appreciated. Thanks in advance
Réponses (0)
Catégories
En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!