11

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?

user31673
  • 13,245
  • 12
  • 58
  • 96

1 Answers1

17

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
Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • Is there any way to make the regular expression case insensitive? – user31673 Sep 01 '12 at 16:56
  • 1
    @user31673 - I believe there is a check box for this in the find options already (if not ticked `Match Case` will be case insensitive). – Oded Sep 01 '12 at 17:19