0

how can I use search for a word but not in commented text, for example i need to find lines contains datatable but not proceeded by single quote

property xxx as datatable
proptery xxx as object 'datatable adasdasdas
'dim x as datatable
dim x as datatable = new xxxx

the search result should highlight these lines, as they contains word datatable and its not proceeded by single quote property xxx as datatable dim x as datatable = new xxxx

thanks

0

3 Answers 3

1
^([^']*datatable.*?)$

Have a look at the DEMO

Sign up to request clarification or add additional context in comments.

1 Comment

You could add word boundaries arround \bdatatable\b
0

Try this: ((?<!')datatable)

It uses a negative look behind, and should work, as Notepad uses PCRE regex.

See here for the example.

For the entire line, what about this?

.*((?<!')datatable).*

See here for the example

Comments

0

To find the line with datatable which is actually a comment and not followed by = new xxx use the following regex.

Regex: (?=.*datatable(?!\s+=\s+new\s+.*))'.*$

Explanation:

  • (?=.*datatable(?!\s+=\s+new\s+.*)) The nesting of negative lookahead inside positive lookahead is done t avoid = new xxx part followed by datatable.

  • '.*$ Matches the rest of comment till end of line.

Regex101 Demo

Notepad++ Demo

Notepad++ Demo

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.