In Visual Studio 2010, how do you look for text that is not within the same line comment?

In Visual Studio 2010, how do you look for text that is not within the same line comment? EG, how to find "bas" in:

foo bar bas 

but not in

 foo bar // bas 

Note that it should find the line:

 foo / bar / bas 

(edit) And he should not find the line:

 foo // bar bas 
+8
regex regex-negation search visual-studio visual-studio-2010
source share
2 answers

Ok, so I asked this question to get back to my own answer.

Visual Studio does not seem to have typical looking-behind constructs. It has a similar negative statement of zero width. The syntax ~ (x) means that the pattern does not match x at this point in the pattern. Using this construct, I came up with the following: ^(.~(//))*bas Which works very well, but does not exclude the line, where // are the first two characters in the line. Correction version: ^~(//)(.~(//))*bas

+6
source share

In the Visual Studio Search dialog box, try using this regular expression (be sure to select Use: Regular Expressions in the Search Options):

 ~(//[.:b]*)<bas> 

This should find all occurrences of the word bas that is not preceded by // .

Note that Visual Studio regex syntax is slightly different than regular syntax. You can find the link HERE .

+6
source share

All Articles