Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab split string multiple delimiters

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?

like image 485
user570593 Avatar asked Oct 31 '12 22:10

user570593


People also ask

How do you separate words in a string in Matlab?

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.

What does Strsplit mean in Matlab?

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 .

What is the default delimiter for split in Matlab?

MATLAB splits on empty space if no delimiter is specified. // default delimiter for matlab is empty string.

What is Strtok Matlab?

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 .


1 Answers

I found it.. Thanks for the replies..

regexp(cellArr, '[_.]', 'split')
like image 150
user570593 Avatar answered Oct 06 '22 18:10

user570593