繁体   English   中英

在Visual Studio中查找C#注释块

[英]Finding blocks of C# comments in Visual Studio

在Visual Studio中使用“查找”命令时,可以使用什么正则表达式来查找C#代码中的注释块(即连续行中的注释),例如

// No need to find single line comment
void Foo()
{
    // I want to find this line.
    // And this line, because they are
    // on consecutive lines
}

有时,我会通过注释掉原始版本来处理代码,处理副本,然后稍后再返回并删除注释掉的原始代码。 我正在寻找一个正则表达式,它将帮助我找到注释掉的代码。

这是一个起点。 这显然错过了/* comment */评论。

//.*\r?\n.*//

//               match // literally
.*               match any character 0 to unlimited times
\r?              match a carriage return optionally
\n               match a new line
.*               match any character 0 to unlimited times
//               match // literally 

如果您用TODO标记注释,即//TODO: Fix this broken thing ,您以后可以在任务列表中轻松找到它们(“查看”菜单,“任务列表”)。

这将完成[\\s\\S]([^a-zA-Z/][^\\n\\r][a-zA-Z/]?//.*[/]*)

参见https://regex101.com/r/wsGNZy/1

暂无
暂无

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

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