Uppercase string from the cell array

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

 采纳的回答

regexp(a,'^[^a-z]+$','match')

2 个评论

It works well
Can give me the small explanation of expression
Thanks a lot
^ % 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 个)

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)

类别

帮助中心File Exchange 中查找有关 Cell Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by