Using regexp to extract labels
Afficher commentaires plus anciens
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!
Réponse acceptée
Plus de réponses (1)
José-Luis
le 27 Déc 2016
filetext = fileread('test.txt');
expr = '(?<=Label:\s+)([\w-\s]+)(?=\n)';
hits = regexp(filetext, expr, 'match')
Catégories
En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!