Why does strtok cut too much out of my string?
Ältere Kommentare anzeigen
Hi,
I am using the strtok function to cut out a certain part of my strings. I have a lot of filenames with the exact string in the beginning of the name and would like to get out the last part of the string.
Eg: Filenmes{1,1} = 'ID_setup_CMJ_L_2' Filenmes{2,1} = 'ID_setup_DJ_R_1'
So I want to get something like:
Names{1,1} = 'CMJ_L_2' Names{2,1} = 'DJ_R_1'
I use the following line for this:
[prt1, prt2] = strtok(filenmes{i,1},'ID_setup_')
It works fine for all of my filenames except for the DJ's.. then it gives me Names({2,1} = 'J_R_1' (instead of DJ_R_1).
Thus, it cuts out that 'D' which it does not do in all of my other examples (CMJ,NonCMJ,HH,...)
Any suggestions? Are there perhaps better ways to do this?
Thanks!
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!