在Visual Studio中搜索时排除注释 [英] Exclude comments when searching in Visual Studio

查看:502
本文介绍了在Visual Studio中搜索时排除注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以在Visual Studio中执行搜索(在文件中查找/查找),从而排除注释中的匹配项?尽管有时它很有用,但有时却相反.对于出现的所有选项,我都认为它会在其中,但是我找不到它.

Is there a way to perform searches (Find / Find in Files) in visual studio that will exclude matches in comments? While sometimes it is useful, other times it is the opposite. For all of the options presented, I figured it would be in there, but I can't find it if it is.

顺便说一句,我正在同等地使用VS 2010/2012.

I am using VS 2010/2012 about equally by the way.

推荐答案

以下是适用于我的Visual Studio较新版本的正则表达式:

Here's the regex that works for me for newer versions of Visual Studio:

^(?![ \t]*//).*your_search_term

请注意,从VS 2012开始,语法已更改:

Note that the syntax changed as of VS 2012:

Visual Studio 2012使用.NET Framework正则表达式来查找和 替换文字.在Visual Studio 2010和更早版本中,Visual Studio在查找和替换"中使用了自定义正则表达式语法 视窗.

Visual Studio 2012 uses .NET Framework regular expressions to find and replace text. In Visual Studio 2010 and earlier versions, Visual Studio used custom regular expression syntax in the Find and Replace windows.

参考: https://msdn.microsoft.com/zh-CN/library/vstudio/2k3te2cs(v = vs.110).aspx

这篇关于在Visual Studio中搜索时排除注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆