开发者

Case insensitive string search

开发者 https://www.devze.com 2022-12-22 13:39 出处:网络
What is the quickest most efficient way to search text for words using non-casesensitive search. E.g here is my text to be searched :

What is the quickest most efficient way to search text for words using non-casesensitive search.

E.g here is my text to be searched :

string textTosearch = "Here is a paragraph or Some text. Here is some more text".

If I wanted to find the indexes of "Some" and "some", is there a .Net class that does this or would I need to use something like regular expressions.

Y开发者_如何学Goour thoughts are much appreciated.

I'm using visual studio 2008.


Take a look at the IndexOf method:

textTosearch.IndexOf("some", StringComparison.OrdinalIgnoreCase);

Other overloads of this method allow you to specify a start index and a number of characters to examine.

0

精彩评论

暂无评论...
验证码 换一张
取 消