How to pick specified matching part of the string
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mekala balaji
el 2 de Dic. de 2017
Comentada: Jan
el 2 de Dic. de 2017
Hi,
I have cell array as shown below:
A050K190E3T15R40
B060L110E8T15R43
F050K230E2T25R40
G050K590E2T15R40
P050L590E2T15R40
I want to take the numerical part left side to the "E" and immediate right side numerical part of "E" and Including "E".
Desired Output:
190E3
110E8
230E2
590E2
590E2
1 comentario
Greg
el 2 de Dic. de 2017
Kudos and thank you for a fantastic post. Formatting, example input and desired output. Makes it easy to answer the question.
Respuesta aceptada
Greg
el 2 de Dic. de 2017
Regular expressions for the win.
out = regexp(in,'\d*E\d*','match','once');
The 'once' means one time per cell element, and greatly simplifies the output if you know for sure there should only be one match in each element.
2 comentarios
Más respuestas (1)
Jan
el 2 de Dic. de 2017
The example looks like you want the substring from the indices 6 to 10:
Data = {'A050K190E3T15R40', ...
'B060L110E8T15R43', ...
'F050K230E2T25R40', ...
'G050K590E2T15R40', ...
'P050L590E2T15R40'};
Result = cellfun(@(c) c(6:10), Data, 'UniformOutput', 0)
1 comentario
Ver también
Categorías
Más información sobre Data Import and Export en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!