MATLAB Answers

take a part from name

조회 수: 1(최근 30일)
Ayman Mounir
Ayman Mounir 2020년 12월 23일
댓글: Ayman Mounir 2020년 12월 23일
Hello everyone;
I have a file name such as file.name='AA_BB_CC12_DD' ; and I want to extract 'CC12' part, but the location of 'CC12' can be in the first part of the file.name or at the end in addition, it could combined with more than one number digit for expample: it can be 'CC5555' or 'CC1'.
Thanks in advance.
Regards,

채택된 답변

Ive J
Ive J 2020년 12월 23일
편집: Ive J 2020년 12월 23일
If the structure of your string always conforms to the above leading/trailing underlines, you can use regexp:
str = 'CC5_ts1_CC534_CC322_F4324_CC1_U84';
regexp(str,'(?<=(_|^))CC\d+', 'match')
1×4 cell array
{'CC5'} {'CC534'} {'CC322'} {'CC1'}
  댓글 수: 1
Ayman Mounir
Ayman Mounir 2020년 12월 23일
Thanks a lot it works and Happy new year

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

추가 답변(0개)

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by