Help with use of regular expression
이전 댓글 표시
Problem: I have a cell array of strings
TrajLocationCompact(1, 3).locationIdCompact1
ans =
'1 1 1 1 1 32'
'29 7 1 1 2 2 2 1 1 29'
'2 1 1 2 1 1 1 1 1 1 1'
'29 29 29 39 39 29'
'29 29 37 29 29 29 29'
'29 3 2 2 1 2 1 1 1 1 1 2'
'29 3 1 1 2 1 1 2 1 2 1 29'
'3 1 1 2 1 1 2 1 1 1'
'29 29 29 29 29 29 29 29 29 1 2 2 16 5 1 1 2 1'
'29 29'
'29'
I want to trasform it in this way
'1 1 1 1 1 32' --> 1 32
'29 7 1 1 2 2 2 1 1 29' --> 29 7 1 2 1 29
'2 1 1 2 1 1 1 1 1 1 1' --> 2 1 2 1
'29 29 29 39 39 29' --> 29 39 29
'29 29 37 29 29 29 29' --> 29 37 29
'29 3 2 2 1 2 1 1 1 1 1 2' --> 29 3 2 1 2 1 2
'29 3 1 1 2 1 1 2 1 2 1 29' --> 29 3 1 2 1 2 1 29
'3 1 1 2 1 1 2 1 1 1' --> 3 1 2 1 2 1
'29 29 29 29 29 29 29 29 29 1 2 2 16 5 1 1 2 1' --> 29 1 2 16 5 1 2 1
'29 29' --> 29
'29' --> 29
Can you help me to find a regular expression that do it?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!