0

我查看了许多有关 VS 正则表达式的 stackoverflow 帖子,并阅读了有关正则表达式的 Microsoft 页面,但仍然无法确定我哪里出错了。

微软 VS 正则表达式

我想找到所有包含单词、属性但不是注释行的行(不包含 // 符号)。

我试过使用正则表达式

~(^ *//).*attribute.*

meaning:
~(^ *//)   --> exclude lines which begin with '//' preceded by zero or more spaces
.*         --> match any character zero or more times
attributes --> match the word attributes
.*         --> match any character that comes after the word attribute

我已经尝试了其他几个失败率大致相同的正则表达式。我想知道是否有人能发现我没有做的明显事情。

我还尝试了以下方法:

~( *//).*attribute.*  (thinking maybe the carat was being taken as a literal instead of special)

~(//).*attribute.* (thinking maybe the * was being taken as a literal instead of special)

~(//)attribute (imminent failure but will try anything)

\s*~(//).*attributes.*

我看到很多帖子建议批量使用 find 命令。这可以做到,但我希望能够双击结果,以便打开文件并滚动到正确的位置。

在此处输入图像描述

4

1 回答 1

0

这个怎么样。

^(?=.*attribute.*\n)(?!.*//).*
于 2014-05-09T22:22:29.913 回答