From: forkandwait w on
Is there a quick way to recode a cell array of strings, preferably using a 2xN cell array of pattern/ code pairs?

For example:

a = {'aa', 'ab', 'cc', 'aa'}
recode (a, {'a.*', 'A'; 'c.*', 'C'})
=> {'A', 'A', 'C', 'A'}

Maybe there is a nice way to do this with cellfun, but there might be an idiom or function special made that I don't know about.