Reputation: 10248
How can I perform a case insensitive search that will find two words that may or may not have a space between them in Visual Studio 2010 e.g.
Foo Bar
FooBar
fooBar
foo bar
EDIT:
Sorry I should have been clearer - I mean a ctrl+shift+f (Edit -> Find and Replace -> Find in Files) search in VS2010 - I don't want to implement this in code - I want to find code/comments etc that matches the search criteria above.
I could also just do four searches... but I am interested to know how to do this in one go, and I would feel more comfortable doing it in one go as I am refactoring.
Cheers Rob
Upvotes: 2
Views: 346
Reputation: 1858
Use the regex:
foo:b*bar
In VS search form:
In code Regex has a case sensitivity option.
Upvotes: 2
Reputation: 22379
You could do it with a single regular expression, but I believe the code will be more readable if you handle each case seprately. Check if the string looks like "FooBar" (maybe using a regex), and if it doesn't, just count the number of spaces in the string (you can use Trim()
) to eliminate the leading and training spaces).
Upvotes: 1