How to separate string and number?

35 visualizaciones (últimos 30 días)
Saroj Nayak
Saroj Nayak el 13 de Oct. de 2018
Respondida: Image Analyst el 8 de Ag. de 2022
For example convert abcdef[123456], pqrst[456], xyz[99] to
  • abcdef | pqrst |xyz
  • 123456 |456 |99
  1 comentario
madhan ravi
madhan ravi el 13 de Oct. de 2018
can you edit the code example properly so that people know the exact format?

Iniciar sesión para comentar.

Respuestas (2)

Star Strider
Star Strider el 13 de Oct. de 2018
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 el 8 de Ag. de 2022

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by