2

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

2 Answers 2

2

Use the regex:

foo:b*bar

In VS search form: enter image description here

In code Regex has a case sensitivity option.

Sign up to request clarification or add additional context in comments.

Comments

1

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).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.