c# - Regular expression behaves differently in Find in Files and in Search current file -
i'm trying find strings in code, while excluding stuff assemblyinfo.cs files, comments , xml content.
i've come regular expression works when use ctrl+f, when trying use "find in files" dialog (ctrl+shift+f), delivers arbitrary result, including empty lines , lines contain e.g. opening curly brace {.
is bug in vs2013? unfortunately don't have other versions available test behavior.
here regular expression , explanation:
^[^\[/<]*\".*\" ^: start of line [^\[/<]*: amount of characters not [, / or < \".*\": amount of characters enclosed 2 quotation marks
when using regular search (ctrl+f), detects lines like
"this test" someobject->dosomething("this test");
and intentionally not detect lines following:
[assembly: assemblytitle("....")] /// <param name="test">test</param>
however, when i'm using "find in files" dialog, same expression lists full implementation of methods including lines braces, class definitions , empty lines.
do have use different syntax or find in files, or not support same features when searching within 1 file?
[edit:] note leaving out [...] expression works intended in both search dialogs
[edit2:] vs version "microsoft visual studio professional 2013, version 12.0.30723.00 update 3"
the regular expression part [^\[/<]*
apparently matches line breaks in "find in files" dialog, unlike regular find dialog.
the problem can solved explicitly excluding \n
both in part of expression , between quotes:
full expression: ^[^\n\[/<]*"[^\n]*"
the (?m)
modifier not supported visual studio 2013, seems ignored, @ least in example.
Comments
Post a Comment