Search code examples
regexmatlabcell-array

How to apply regexp to the cell array in Matlab?


I'm having the cell array res with cells 3x2, each of them containing a string. I want to apply regexp to each cell and it should look like that:

fin = cellfun(@regexp(res, '\.', 'split'),res,'UniformOutput',false)

however it doesn't do the job. Anyone knows how it can be combined properly?


Solution

  • You were on the right track, but the syntax of your anonymous function is wrong. Try this:

    fin = cellfun(@(x)regexp(x, '\.', 'split'), res, 'UniformOutput', false)