extract word before and after character
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
aldo
el 19 de Dic. de 2023
Comentada: aldo
el 20 de Dic. de 2023
i want to extract string before "(" and after " " or "," (space comma)
example:
input: pilo(52),iko(54);
result:
pilo
iko
4 comentarios
Respuesta aceptada
Stephen23
el 20 de Dic. de 2023
Editada: Stephen23
el 20 de Dic. de 2023
C = {'input: pilo(52),iko(54)'; 'input:iko(54)'; 'input:pilo(52),iko(54)'; 'input:pilo(52),iko(54),op(23)'}
X = regexp(C,'(\w+)\((\d+)','tokens');
X = cellfun(@(c)vertcat(c{:}),X,'uni',0)
X{:}
However... regular expressions are very precise things. Writing them well requires understanding the precise conditions that they should match. Thus usually when someone posts a question with "simplified" text it just delays getting a working solution.
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Type Conversion 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!