Regular expression behaves differently in Find in Files and current search file

I am trying to find all lines in my code excluding things like AssemblyInfo.cs files, comments and XML content.

I came up with a regex that works when I use it with Ctrl+ F, however when I try to use it in the Find Files ( Ctrl+ Shift+ F) dialog , it provides an arbitrary result, including even blank lines and lines that only contain: the opening curly parenthesis {.

Is this a bug in VS2013? I unfortunately have no other versions available to test this behavior.

Here's the regex and its explanation:


^: Start of line
[^\[/<]*: Any amount of characters which are not [, / or <
\".*\": Any amount of characters enclosed by two quotation marks


When used with normal search ( Ctrl+ F), it correctly identifies strings like

  "This is a test"
  someObject->doSomething("This is a test");


and deliberately doesn't detect lines like:

 [assembly: AssemblyTitle("....")]
 /// <param name="Test">Test</param>


However, when I use the Find in Files dialog, the same expression lists the full implementation of some of the methods, including lines with only curly braces, class definitions, and empty lines.

Should I use a different syntax or something with Find in Files, or does it not support the same functionality as when searching in a single file?

[Edit:] Note that excluding the expression [...] works the same in both search dialogs

[Edit2:] VS Version: "Microsoft Visual Studio Professional 2013 Version 12.0.30723.00 Update 3"


source to share

1 answer

The regex element [^\[/<]*

appears to match the line breaks in the Find Files dialog, as opposed to the regular Find dialog.

The problem can be solved by explicitly excluding \n

both in this part of the expression and between the quotes:

Full Expression: ^[^\n\[/<]*"[^\n]*"


The modifier (?m)

is probably not supported by Visual Studio 2013, it seems to be ignored, at least in this example.



All Articles