how to delete part of a string
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohammed Kamruzzaman
am 21 Apr. 2015
Kommentiert: Star Strider
am 22 Apr. 2015
I have thousands of string variables from where I want to delete some character (both from start and end). For example I want to convert
'TENSOR 27_SN2837_CSN_PROV1_20130209.0.csv' to CSN_PROV1_20130209
'TENSOR 27_SN2837_CSN_WADC1_20131004.0.csv' to CSN_WADC1_20131004
............
...........
Any suggestions?. Thanks
0 Kommentare
Akzeptierte Antwort
Star Strider
am 21 Apr. 2015
There may be more efficient ways to do this, but if all the original strings are the same length, this works:
V = ['TENSOR 27_SN2837_CSN_PROV1_20130209.0.csv'
'TENSOR 27_SN2837_CSN_WADC1_20131004.0.csv'];
for k1 = 1:size(V,1)
I1 = strfind(V(k1,:), 'CSN');
I2 = strfind(V(k1,:), '.0');
W(k1,:) = V(k1,I1:I2-1);
end
producing:
W =
CSN_PROV1_20130209
CSN_WADC1_20131004
6 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!