Search an entire text file for a word
조회 수: 9 (최근 30일)
이전 댓글 표시
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
채택된 답변
Cedric
2017년 10월 12일
content = fileread( 'MyTextFile.txt' ) ;
and then you can STRFIND or REGEXP or anything else on content, which is a char array.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!