Using regexp to extract labels
Mostrar comentarios más antiguos
Hi,
I have a file (attached) which includes some header information I am interested in. Specifically, I would like to extract the various channel labels, but can't quite correct the expression in order to obtain all of the label names in the file and nothing else. I have tried
labels = regexp(filetext, '((?<=Label:)(\s*\w*){2}\D*\d*)+', 'match');
although this doesn't quite work due to the first two channel labels being in a different format to the rest. If anyone can offer advice so that I can fix my expression to work for the first two channel labels also, that would be greatly appreciated.
Thank you kindly in advance!
Respuesta aceptada
Más respuestas (1)
José-Luis
el 27 de Dic. de 2016
filetext = fileread('test.txt');
expr = '(?<=Label:\s+)([\w-\s]+)(?=\n)';
hits = regexp(filetext, expr, 'match')
Categorías
Más información sobre Characters and Strings 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!