MATLAB: How to use negation in regexp in matlab

negationregexp

I have a cellarray x = {:123214,-136355}; I wish to write a condition that stores the value in cellarray that does not recognize the : special character. How could I do the negation ~= using regexp? I tried this but it didnt work:
j = 1;
for k =1:length(x)
if ~(regexp(x{k},'^:.*','match')
a{j} = x{k};
j++
end
end

Best Answer

Using regexp is overkill here, as all you are checking is the first character of the string. Much simpler would be to use strncmp:
>> x = {':123214','-136355'};
>> strncmp(x,':',1)
ans =
1 0
which is obviously trivial to use as indexing:
>> x(~strncmp(x,':',1)) % negated
ans =
'-136355'
>> x(strncmp(x,':',1)) % not negated
ans =
':123214'