How to separate string and number?

조회 수: 32 (최근 30일)
Saroj Nayak
Saroj Nayak 2018년 10월 13일
답변: Image Analyst 2022년 8월 8일
For example convert abcdef[123456], pqrst[456], xyz[99] to
  • abcdef | pqrst |xyz
  • 123456 |456 |99
  댓글 수: 1
madhan ravi
madhan ravi 2018년 10월 13일
can you edit the code example properly so that people know the exact format?

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

답변 (2개)

Star Strider
Star Strider 2018년 10월 13일
This is a rather trivial regexp (link) call:
str = 'abcdef[123456], pqrst[456], xyz[99]';
out_all= regexp(str, '\w*\d*', 'match');
out_str = out_all(1:2:end)
out_num = out_all(2:2:end)
out_str =
{'abcdef'} {'pqrst'} {'xyz'}
out_num =
{'123456'} {'456'} {'99'}

Image Analyst
Image Analyst 2022년 8월 8일

카테고리

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