How to split a numrical-charcater String
이전 댓글 표시
I want to split the string "R88L1R607L10R1293" such that I should get "R", "88", "L", "1", "R", "607", "L", "10", "R", "1293".
답변 (2개)
Akira Agata
2018년 1월 17일
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
2018년 1월 17일
>> 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
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!