converting cells with strings inside cells into strings inside cells

1 view (last 30 days)
I use the following code: cellfun(@(x) regexp(x, '@(.*)@', 'tokens'), array_of_strings) The idea is to replace all the strings in the array with only the substring between the @'s. It works, the only problem is that the 'tokens' option leaves me with cells inside cells, which is inconvenient. My questions are: 1. Is there an alternative way to do it without getting cells inside cells? 2. It is interesting for me to know if there is a function that converts "cell arrays with strings inside a cell array" into simply "strings in a cell array". Thanks

Accepted Answer

Paolo on 24 Jul 2018
Edited: Paolo on 24 Jul 2018
cellfun(@(x) regexp(x,'(?<=@)(.*)(?=@)','match'),array_of_strings)
cellfun(@(x) regexp(x,'(?<=@)(.*)(?=@)','tokens','once'),array_of_strings)

Sign in to comment.

More Answers (0)




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!