Uppercase string from the cell array

8 visualizaciones (últimos 30 días)
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan el 12 de Ag. de 2015
Editada: Stephen23 el 12 de Ag. de 2015
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 comentario
Stephen23
Stephen23 el 12 de Ag. de 2015
+1 for a clear question with input and output examples.

Iniciar sesión para comentar.

Respuesta aceptada

Stephen23
Stephen23 el 12 de Ag. de 2015
Editada: Stephen23 el 12 de Ag. de 2015
regexp(a,'^[^a-z]+$','match')
  2 comentarios
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan el 12 de Ag. de 2015
Editada: Stephen23 el 12 de Ag. de 2015
It works well
Can give me the small explanation of expression
Thanks a lot
Stephen23
Stephen23 el 12 de Ag. de 2015
Editada: Stephen23 el 12 de Ag. de 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:

Iniciar sesión para comentar.

Más respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 12 de Ag. de 2015
Editada: Azzi Abdelmalek el 12 de Ag. de 2015
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)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by