user31673
user31673

Reputation: 13695

In Visual Studio 2010 search for two strings within single lines of c# code

I am using Visual Studio 2010 with c#. I need to search my codebase for find all lines of code where two strings are found in the single line of code (the line of code could span multiple lines which c# allows). The two strings are not connected and I don't know what will be between them. I just want to find all occurances where it finds both strings in the line of code. Is there anyway to do this? Is there another tool outside of Visual Studio that would allow this type of search?

Upvotes: 11

Views: 6112

Answers (1)

Oded
Oded

Reputation: 499072

You can use regular expressions to search for files within Visual Studio - no need for external tools for this (though, of course, you can use grep if you so wish).

See Using Regular Expressions in Visual Studio - the syntax is somewhat esoteric in that it doesn't conform to most regular expression dialects currently in use (it is different from the .NET one for sure).

Something like:

string1.+string2

Should work. If you need this in either order, try:

string1.+string2|string2.+string1

Upvotes: 17

Related Questions