Remove all remaining charaters once the first non digit occurs within a vector of an array and keep everything before the non digit
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Tim Moriarty
el 8 de Abr. de 2016
Respondida: Azzi Abdelmalek
el 8 de Abr. de 2016
I have an input with a column that has an ID in it. The ID looks like this, '2270|1|60'. I need to remove everything to the right of the first line within this vector, so that every value looks like 2270 for the ID. That said the position of the first '|' can vary as the ID number changes down the ID column, so the code needs to look for the most left '|', and then remove all other charaters after (including the first '|') that for each ID number.
0 comentarios
Respuesta aceptada
Fangjun Jiang
el 8 de Abr. de 2016
Editada: Fangjun Jiang
el 8 de Abr. de 2016
a={'22702270|1|60';
'2270|1|60';
'227022702270|1|60'};
b=regexprep(a,'\|.+','')
b =
'22702270'
'2270'
'227022702270'
0 comentarios
Más respuestas (1)
Azzi Abdelmalek
el 8 de Abr. de 2016
a={'2270|1|60';'223570|1|60'}
out=regexp(a,'\d+(?=|)','match','once')
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!