Case-sensitive case-sensitive search

What is the fastest most efficient way to search for text for words using insensitive search.

For example, here is my search text:

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

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

Your thoughts are greatly appreciated.

I am using visual studio 2008.

+4
source share
1 answer

Take a look at the IndexOf method:

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

Other overloads of this method allow you to specify the starting index and the number of characters to be checked.

+7
source

Source: https://habr.com/ru/post/1303268/


All Articles