Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaowenqiang/5003900eaf4bf13eb144657137319f08 to your computer and use it in GitHub Desktop.
Save yaowenqiang/5003900eaf4bf13eb144657137319f08 to your computer and use it in GitHub Desktop.
Regex to search only between uncommented lines (NCLOC - Non-Comment Lines Of Code)
Search only between uncommented lines (NCLOC - Non-Comment Lines Of Code):
First solution matches "keyWord" which is not commented with single line comment //
^*(?<!\/\/.*)keyWord // this uses negative lookbehind
or another solution without lookbehind for regex engines, that does not support it:
^[^//]*keyWord
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment