Search an entire text file for a word
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Lauren Harkness
le 12 Oct 2017
Réponse apportée : Cedric
le 12 Oct 2017
If i have a text file and am looking for the number of times a specific word appears in it, how would I go about doing that? I tried using the "contains" and "strfind" but they aren't working because its a text file not a string.
0 commentaires
Réponse acceptée
Cedric
le 12 Oct 2017
content = fileread( 'MyTextFile.txt' ) ;
and then you can STRFIND or REGEXP or anything else on content, which is a char array.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!