Uppercase string from the cell array

9 ビュー (過去 30 日間)
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan 2015 年 8 月 12 日
編集済み: Stephen23 2015 年 8 月 12 日
I have a cell array a = {'AA_DFA_DD' ,'DSFA_dfaf' ,'DDDD' , 'DFE1' ,'dfs_DD'}
How can extract only the upper case string from the cell array
my answer should be {'AA_DFA_DD',[],'DDDD','DFE1',[]}
How can i do this?
Thanks a lot
  1 件のコメント
Stephen23
Stephen23 2015 年 8 月 12 日
+1 for a clear question with input and output examples.

サインインしてコメントする。

採用された回答

Stephen23
Stephen23 2015 年 8 月 12 日
編集済み: Stephen23 2015 年 8 月 12 日
regexp(a,'^[^a-z]+$','match')
  2 件のコメント
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan 2015 年 8 月 12 日
編集済み: Stephen23 2015 年 8 月 12 日
It works well
Can give me the small explanation of expression
Thanks a lot
Stephen23
Stephen23 2015 年 8 月 12 日
編集済み: Stephen23 2015 年 8 月 12 日
^ % match start of string
[^a-z] % match any character EXCLUDING lower-case
+ % repeated one or more times
$ % match end of string
These are all explained in the documentation:

サインインしてコメントする。

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 8 月 12 日
編集済み: Azzi Abdelmalek 2015 年 8 月 12 日
out=a(cellfun(@(x,y) isequal(x,y),a,upper(a)))
or
out=cell(size(a))
idx=cellfun(@(x,y) isequal(x,y),a,upper(a))
out(idx)=a(idx)
  1 件のコメント
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan 2015 年 8 月 12 日
thanks a lot

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by