简体   繁体   English

Visual Studio中的正则表达式搜索

[英]Regex search in visual studio

I am trying to find all string literals in Visual Studio which are not empty and not commented out, so I'm using the regular expression search 我试图在Visual Studio中找到所有不为空且未注释掉的字符串文字,所以我正在使用正则表达式搜索

^((?!//).)*".+"

Which I'm hoping will match the line 我希望能与这条线匹配

 get { return System.Environment.UserName.ToUpper() == "MYUSERNAME"; }

but not 但不是

/// Initializes a new instance of the <see cref="ApplicationContext"/> class.

This seems to match what I want on the regex tester at http://regexpal.com but in Visual studio it gives no results. 这似乎与我在http://regexpal.com上的正则表达式测试器上想要的匹配,但在Visual Studio中却没有任何结果。

What could be going wrong here? 这里可能出什么问题了?

Older versions of Visual Studio (before 2012) used their own dialect of regular expressions that are very different to .NET's dialect. Visual Studio的较早版本(2012年之前)使用自己的正则表达式方言,该方言与.NET的方言非常不同。

Help for VS's dialect is on MSDN . VS的方言帮助位于MSDN上

Edit : It was VS2012 that switched to using .NET regular expressions. 编辑 :是VS2012切换为使用.NET正则表达式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM