在Visual Studio 2010中,如何搜索不在单行注释中的文本? [英] In Visual Studio 2010, how do you search for text that is not within a single line comment?
问题描述
在Visual Studio 2010中,如何搜索不在单行注释中的文本? E. G.如何在以下位置找到"bas":
In Visual Studio 2010, how do you search for text that is not within a single line comment? E. G. how to find "bas" in:
foo bar bas
但不在
foo bar // bas
请注意,它应该找到以下行:
Note that it should find the line:
foo / bar / bas
(edit)并且它找不到该行:
(edit) And it should not find the line:
foo // bar bas
推荐答案
好的,所以我问了这个问题,以便可以参考自己的答案.
Okay, so I asked this question just so I could refer back to my own answer.
Visual Studio似乎没有典型的先行先后构造.它确实具有类似的零宽度否定断言.语法为〜(x),这意味着模式在此点与x不匹配.使用此构造,我想到了:^(.~(//))*bas
确实很好用,但是不会排除其中//是该行的前两个字符的行.要修复的版本为:^~(//)(.~(//))*bas
Visual Studio doesn't seem to have the typical look-ahead, look-behind constructs. It does have a similar zero-width negative assertion. The syntax is ~(x) which means the pattern does not match x at this point in the pattern. Using this construct, I came up with this: ^(.~(//))*bas
Which works really well, but won't exclude a line where // are the first two characters on the line. A version to fix that is: ^~(//)(.~(//))*bas
这篇关于在Visual Studio 2010中,如何搜索不在单行注释中的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!