case insensitive strfind?

64 次查看(过去 30 天)
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

更多回答(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