Using regexp to extract labels
이전 댓글 표시
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!
채택된 답변
추가 답변 (1개)
José-Luis
2016년 12월 27일
filetext = fileread('test.txt');
expr = '(?<=Label:\s+)([\w-\s]+)(?=\n)';
hits = regexp(filetext, expr, 'match')
카테고리
도움말 센터 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!