필터 지우기
필터 지우기

Complicated Question / String Arrays

조회 수: 3 (최근 30일)
Max Müller
Max Müller 2014년 7월 24일
댓글: dpb 2014년 7월 24일
Hey Guys, i have an array of strings which looks like this:
'J_012(105)' 'J_013(106)' 'J_014(107)' 'J_015(2)' J_016(94)' 'J_017(95)'
But I need it to look like this:
'J_012' 'J_013' 'J_014' 'J_015' 'J_016' 'J_017'
So That the ALWAYS the last 4Strings are deleted/kill. Is this possible ?

채택된 답변

dpb
dpb 2014년 7월 24일
new= cellfun(@(x) x(1:5),old,'uniformoutput',false);
  댓글 수: 2
Max Müller
Max Müller 2014년 7월 24일
Thanks..both ways wokr
dpb
dpb 2014년 7월 24일
If the pattern isn't fixed length, then regexp is useful; if it is then it's overkill...good to see both

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 7월 24일
A={'J_012(105)' 'J_013(106)' 'J_014(107)' 'J_015(2)' 'J_016(94)' 'J_017(95)'}
B=cellfun(@(x) x{1} ,regexp(A,'.+(?=\()','match'),'un',0)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by