case insensitive strfind?

조회 수: 84 (최근 30일)
New
New 2011년 7월 24일
댓글: Tord Bjørnevaagen 2017년 8월 11일
I have a matrix in which there are about 100,000 sentences that I want to scan for the existence of certain words (True/false). For previous scans, searching for one exact word, I used the strfind. Nevertheless, now I have a list of 18 words which might be written in lower or upper cases in the sequences. The strcmpi which could be useful in this case only returns positive if the whole sentence consist of the word... Is there another function I missed?
Thank you

채택된 답변

Titus Edelhofer
Titus Edelhofer 2011년 7월 24일
Hi,
one simple method would be to use lower on both the sentences and the words you are using ...
Titus
  댓글 수: 1
Tord Bjørnevaagen
Tord Bjørnevaagen 2017년 8월 11일
I just used this solution, thanks!
strfind(lower(bigText),lower(keyword))

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Fangjun Jiang
Fangjun Jiang 2011년 7월 24일
use regexpi
  댓글 수: 1
Turner
Turner 2013년 8월 20일
takes 10 times longer than lower/upper followed by strfind() in my benchmark

댓글을 달려면 로그인하십시오.


Bjorn Gustavsson
Bjorn Gustavsson 2011년 7월 24일
Use: strcmpi
  댓글 수: 2
Walter Roberson
Walter Roberson 2011년 7월 25일
strcmpi() is not suitable for substring searches. See http://www.mathworks.com/help/techdoc/ref/strcmpi.html about what it _does_ do.
Bjorn Gustavsson
Bjorn Gustavsson 2011년 7월 25일
I misread the original poster's strfind as strcmp...

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by