How to separate string and number?

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일

0 개 추천

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'}

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

질문:

2018년 10월 13일

답변:

2022년 8월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by