Yellow75 :
In Visual Studio Code, I would like to replace, in all project files, all instructions log.info NOT equal to:
log.info(
`DEBUG other strings...
);
with nothing (I want to delete them in all files); for example, this log.info should be removed:
log.info(
`remove this instruction!!!
);
but not this (it has DEBUG has first word):
log.info(
`DEBUG other strings...
);
Pay attention, log.info() could be also on a single line, for example:
log.info(`remove this instruction!!!);<br>
log.info(`DEBUG other strings...);<br>
I have tried this, with no result:
log.(info|warn|error)\([\n|\s]`*(?!DEBUG).*\)
Wiktor Stribiżew :
You may use
\blog\.(?:info|warn|error)\((?!\s*`DEBUG\b)[\w\W]*?\);
See the regex demo.
Details
\b
- a word boundarylog\.
-log.
string(?:info|warn|error)
- eitherinfo
,warn
orerror
\(
- a(
char(?!\s*
DEBUG\b)- a negative lookahead that fails the match if, immediately to the right of the current location, there is 0+ whitespaces, a backtick,
DEBUG` as whole word[\w\W]*?
- any 0 or more characters, as few as possible\);
- a);
substring.
Test & settings:
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=398871&siteId=1