case insensitive strfind?

92 views (last 30 days)
New on 24 Jul 2011
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

Accepted Answer

Titus Edelhofer
Titus Edelhofer on 24 Jul 2011
one simple method would be to use lower on both the sentences and the words you are using ...
  1 Comment
Tord Bjørnevaagen
Tord Bjørnevaagen on 11 Aug 2017
I just used this solution, thanks!

Sign in to comment.

More Answers (2)

Fangjun Jiang
Fangjun Jiang on 24 Jul 2011
use regexpi
  1 Comment
Turner on 20 Aug 2013
takes 10 times longer than lower/upper followed by strfind() in my benchmark

Sign in to comment.

Bjorn Gustavsson
Bjorn Gustavsson on 24 Jul 2011
Use: strcmpi
Walter Roberson
Walter Roberson on 25 Jul 2011
strcmpi() is not suitable for substring searches. See about what it _does_ do.
Bjorn Gustavsson
Bjorn Gustavsson on 25 Jul 2011
I misread the original poster's strfind as strcmp...

Sign in to comment.


Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!