MATLAB: Part of file name

MATLABpart of the nameregexp

If I have a file name such as ' Hello_World_2020 ', I want to take the part between the underscores ' world ', how I would do that.
Regards.

Best Answer

s = 'Hello_World_2020';
c = regexp(s, '_', 'split') ;
c{2}
You can also use strsplit() instead of regexp. On the other hand, strsplit() invokes regexp internally.