Skip to content

Instantly share code, notes, and snippets.

@trebron21
Last active February 16, 2023 03:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save trebron21/9222f676cf76cdc6fb0f to your computer and use it in GitHub Desktop.
Save trebron21/9222f676cf76cdc6fb0f 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