MATLAB Answers

0

Find the string from the cell array

Latest activity Edited by Azzi Abdelmalek
on 12 Aug 2015
I have a cell array containg a = {'s_ddfa_af' ; 'adfa' ; 'f_dsfa_dasf_sdf'; 'asdf_dd'};
I need to extract the string starting with 's'
When I use regular expression regexpi( a , 's(\w*)' ,'match')
I am getting as {'s_ddfa_af' ; [] ; 'sfa_dasf_sdf' ; 'sdf_dd'}
but i need only the string starting with 's'
How can i do this??
Thanks a lot

  0 Comments

Sign in to comment.

1 Answer

Answer by Azzi Abdelmalek
on 12 Aug 2015
Edited by Azzi Abdelmalek
on 12 Aug 2015
 Accepted Answer

a = {'s_ddfa_af' ; 'adfa' ; 'f_dsfa_dasf_sdf'; 'asdf_dd'};
out=regexpi(a,'^s\w*','match')

  0 Comments

Sign in to comment.