Exclude comments when searching in Visual Studio

前端 未结 3 1797
無奈伤痛
無奈伤痛 2020-12-14 05:39

Is there a way to perform searches (Find / Find in Files) in visual studio that will exclude matches in comments? While sometimes it is useful, other times it is the opposi

3条回答
  •  盖世英雄少女心
    2020-12-14 06:32

    you could try the regex as below:

    ^~(:b*//).*your_search_term
    

    Short explanation:

    • ^ from beginning of line
    • ~( NOT the following
    • :b* any number of white spaces, followed by
    • // the comment start
    • ) end of NOT
    • .* any character may appear before
    • your_search_term your search term :-)

    saw this at another post.

提交回复
热议问题