New string based on parts of old string
Mostrar comentarios más antiguos
How do I get new str from this old string? All the strings are in this format. Is there a way to extract based on the position from '(' and after '|'?
OldStr1 = 'Extract clusters: PR (2 files) | DG_MD_CG_22'
OldStr2 = 'Extract clusters: OR (2 files) | AG_MD_HH_CG_HH_22'
NewStr1 = 'DG_MD_CG_22_PR'
NewStr2 = 'AG_MD_HH_CG_HH_22_OR'
Respuesta aceptada
Más respuestas (1)
I would use the extract* functions listed in the Join and Split section of the Characters and Strings category page in the documentation.
s = 'hocus pocus'
h = extractBefore(s, ' ')
p = extractAfter(s, ' ')
1 comentario
DavidL88
el 14 de Dic. de 2021
Categorías
Más información sobre Environment and Settings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!