Search an entire text file for a word

12 visualizaciones (últimos 30 días)
Lauren Harkness
Lauren Harkness el 12 de Oct. de 2017
Respondida: Cedric el 12 de Oct. de 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.

Respuesta aceptada

Cedric
Cedric el 12 de Oct. de 2017
content = fileread( 'MyTextFile.txt' ) ;
and then you can STRFIND or REGEXP or anything else on content, which is a char array.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by