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 Kommentar

Stephen23
Stephen23 am 12 Aug. 2015
+1 for a clear question with input and output examples.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Stephen23
Stephen23 am 12 Aug. 2015
Bearbeitet: Stephen23 am 12 Aug. 2015

1 Stimme

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

2 Kommentare

Gopalakrishnan venkatesan
Gopalakrishnan venkatesan am 12 Aug. 2015
Bearbeitet: Stephen23 am 12 Aug. 2015
It works well
Can give me the small explanation of expression
Thanks a lot
Stephen23
Stephen23 am 12 Aug. 2015
Bearbeitet: Stephen23 am 12 Aug. 2015
^ % 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:

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 12 Aug. 2015
Bearbeitet: Azzi Abdelmalek am 12 Aug. 2015

2 Stimmen

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)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by