Searching word list for key letters
Show older comments
wordList = {'apples'
'orange'
'banana'};
ContainList = 'shu';
NotContainList = 'br';
I'd like to be able to find all words that contain the letters S,H or U and do not have the letters B or R. I'm using 'contains' for each letter but is there a way to loop through the ContainList/NotContainList for each word?
Accepted Answer
More Answers (1)
David Hill
on 24 Jan 2022
wordList = {'apples','orange','banana','show','unit'};
ContainList = 'shu';
NotContainList = 'br';
r=wordList(contains(wordList,num2cell(ContainList))&~contains(wordList,num2cell(NotContainList)));
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!