Search an entire text file for a word

9 vues (au cours des 30 derniers jours)
Lauren Harkness
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.

Réponse acceptée

Cedric
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.

Plus de réponses (0)

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!

Translated by