Is there any way to restrict the Find/Search to uncommented lines only ?
(Maybe using regex would be a good lead)
Asked
Active
Viewed 2,475 times
9

Mehdi LAMRANI
- 11,289
- 14
- 88
- 130
-
1You can always collapse the commented code and uncheck "search hidden text". – bzlm Sep 23 '11 at 10:21
-
Not a direct duplicate, but I asked a related question a while ago and got some helpful suggestions: http://stackoverflow.com/questions/2872946/are-there-any-context-sensitive-code-search-tools – Vicky Sep 23 '11 at 10:37
-
1@bzlm: Dude, I am searching the entire solution :-) – Mehdi LAMRANI Sep 23 '11 at 10:56
-
1regex will definitely work for lines starting with // but it's going to be some crazy regex to skip those contained in /**/ – stijn Sep 23 '11 at 11:16
-
Is there a solution for VS 2015? I tried the only given answer but it didn't seem to work and instead would never find anything.. – Alox Oct 11 '18 at 13:40
1 Answers
5
Lets say, if you need to search all occurrences of an uncommented text "VPEntity" then try using the following regular expression in Find in files after selecting the Use RegEx option
^((?!//|/\*).)*VPEntity
Hope it works for you

Wiktor Stribiżew
- 607,720
- 39
- 448
- 563

Azfar
- 59
- 1
- 2
-
1or use this ^((?!//|/\*).)*VPEntity*$ or you can tweak it as per your need using any RegEx Builder tool – Azfar Apr 25 '12 at 08:09
-
2and for VB.Net code it is `^((?!').)*VPEntity.*$` The .+ at the end is important, otherwise it won't match unless VPEntity is at the end of the line. This could be more robust I'm sure since a ' anywhere before the term in the line will prevent a match, not just the beginning. – MHollis Jul 10 '13 at 18:02