MATLAB: Find indices of string matches from a cell array by thier endings

cell arraysfindMATLABstring

I want to find the indices of a cell array whose memembers end with a specific string. Eg.
A={'aAbc' 'dgbc' 'bebd' 'fabc' 'fa '}
Now if I want to find out the indices of the strings which end either with two characters'bc' or ' ' (empty), which command in Matlab would be suitable for this ?

Best Answer

Do it without loops to make it a bit faster:
A={'aAbc' 'dgbc' 'bebd' 'fabc' 'fa ' 'abcd' 'abcdkads' 'a' 'snacks bc'};
myindices = ~cellfun(@isempty,regexp(A,'bc$'))