Compare .txt to a string.
Show older comments
How can you compare each line of a .txt file to a string?
Accepted Answer
More Answers (1)
Guillaume
on 23 Feb 2015
filelines = strsplit(fileread('sometextfile'), '\n');
issamestring = strcmp(filelines, 'stringtomatch')
2 Comments
per isakson
on 23 Feb 2015
Use strtrim to avoid trailing space of the text file.
Guillaume
on 23 Feb 2015
That's assuming you don't want to compare the spaces.
Categories
Find more on String Parsing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!