Uppercase string from the cell array

6 次查看(过去 30 天)
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

采纳的回答

Stephen23
Stephen23 2015-8-12
编辑:Stephen23 2015-8-12
regexp(a,'^[^a-z]+$','match')
  2 个评论
Gopalakrishnan venkatesan
编辑: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)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by