finding a string in a character array
13 ビュー (過去 30 日間)
古いコメントを表示
Good day people.please I need your help.
If a user inputs a character array of strings in the edit box,and he clicks on the pushbutton,I need a code that will check if the input:
has the letter A :disp'it is upi dialect'.
has the letter R :disp'it is iri dialect'.
has the letter Y and E :it is ibakwa dialect'
contains a word that ends with letter S :it is udi dialect'
note the letters are case insensitive
回答 (1 件)
Jan
2016 年 3 月 19 日
Add in the callback of the edit field:
Str = get(EditH, 'String');
% Is it a multi-line edit field? Then convert it to a string at first:
if iscell(Str)
Str = sprintf('%s\n', Str{:});
end
lowStr = lower(Str);
if any(strfind(lowStr, 'a'))
disp('it is upi dialect');
elseif any(strfind(lowStr, 'r'))
disp('it is iri dialect');
elseif any(strfind(lowStr, 'y')) || any(strfind(lowStr, 'e'))
disp('it is ibakwa dialect');
elseif any(lowStr, 's\>') % contains a word that ends with letter S:
disp('it is udi dialect');
else
disp('???');
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!