views:

115

answers:

1

Hi There, 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 string that does this or would i need to use something like regular expressions. Your thoughts are much appreciated. Im using visual studio 2008.

+5  A: 

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.

Darin Dimitrov
Faster than me :) +1
Paolo Tedesco