If I use "Find in Path" (ctrl-shift-f) I see result in import statements, too:
I am not interested in the from ... import ...
lines.
How to remove them from "Find in Path"?
If I use "Find in Path" (ctrl-shift-f) I see result in import statements, too:
I am not interested in the from ... import ...
lines.
How to remove them from "Find in Path"?
The only way I know of to do this in current editions is to use a regex:
(?<!import )logged_in_or_basicauth
This uses a negative lookbehind to ensure that any matches that have the word import
and a single space preceding logged_in_or_basicauth
will be excluded from the results.
Note that quantifiers like +
and *
cannot be used in lookbehinds, so we can't make this regex handle multiple spaces between import
and logged_in_or_basicauth
aside from simply hardcoding more spaces after import
.
I voted for your feature request on YouTrack, good idea opening it there.
Seems that JetBrains IDE doesn't have such feature, the question turns to be "find a string which contains target
but doesn't contain import
". So see this: Regular expression for a string containing one word but not another
Use ^(?!.*import).*target.*$
.
Test cases:
from whatever import target;
import whatever from target;
target;
whatever target;
The problem is it will highlight other words.
Reg101 result: Reg101 result