How to split a numrical-charcater String
Ältere Kommentare anzeigen
I want to split the string "R88L1R607L10R1293" such that I should get "R", "88", "L", "1", "R", "607", "L", "10", "R", "1293".
Antworten (2)
Akira Agata
am 17 Jan. 2018
You can separate it by using regexp function, like:
strAll = "R88L1R607L10R1293";
strNum = regexp(strAll,'\d+','match'); % Extract numbers
strChar = regexp(strAll,'[A-Z]+','match'); % Extract alphabets
Stephen23
am 17 Jan. 2018
>> S = 'R88L1R607L10R1293';
>> C = regexp(S,'([RL])(\d+)','tokens');
>> C = [C{:}];
>> C{:}
ans = R
ans = 88
ans = L
ans = 1
ans = R
ans = 607
ans = L
ans = 10
ans = R
ans = 1293
Kategorien
Mehr zu Data Type Conversion 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!