0
votes

I am currently using 'strsplit' function in Matlab as:

char(strsplit(cell2str({'ASD13456D34567'}),'ASD')')

The output of this is:

ans =

13456
34567

Instead, I want to have output as:

13456D34567

How do I achieve this ?

I have a cell array of strings. Here I just used one element of the array for illustration.

2

2 Answers

3
votes

If you want to split strings:

regexp({'ASD13456D34567','test'},'ASD','split') %// split according to 'ASD'

Or if you just want to remove 'ASD', without splitting:

regexprep({'ASD13456D34567','test'},'ASD','') %// replace 'ASD' by empty string
0
votes

Just do it like this:

char(strsplit('ASD13456D34567','ASD'))