I have a cell list of strings like this:
cellArr =
'folderName_fileName_no.jpg',
'folderName2_fileName2_no2.jpg'
I want to get it like this
{folderName, fileName, no},
{folderName2, fileName2, no2}
How to do it in matlab? I know I can use
regexp(cellArr, '_', 'split'),
but how can I use more than one delimiters?
newStr = split( str ) divides str at whitespace characters and returns the result as the output array newStr . The input array str can be a string array, character vector, or cell array of character vectors. If str is a string array, then so is newStr . Otherwise, newStr is a cell array of character vectors.
The strsplit function splits str on the elements of delimiter . The order in which delimiters appear in delimiter does not matter unless multiple delimiters begin a match at the same character in str . In that case strsplit splits on the first matching delimiter in delimiter .
MATLAB splits on empty space if no delimiter is specified. // default delimiter for matlab is empty string.
Description. token = strtok( str ) parses str from left to right, using whitespace characters as delimiters, and returns part or all of the text in token .
I found it.. Thanks for the replies..
regexp(cellArr, '[_.]', 'split')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With