Yellow75:
En código de Visual Studio, me gustaría sustituir, en todos los archivos de proyecto, todas las instrucciones NO log.info igual a:
log.info(
`DEBUG other strings...
);
sin nada (quiero eliminarlos en todos los archivos); por ejemplo, este log.info debe retirarse:
log.info(
`remove this instruction!!!
);
pero no esto (que ha de depuración tiene la primera palabra):
log.info(
`DEBUG other strings...
);
prestar atención, log.info () podría ser también en una sola línea, por ejemplo:
log.info(`remove this instruction!!!);<br>
log.info(`DEBUG other strings...);<br>
He intentado esto, sin ningún resultado:
log.(info|warn|error)\([\n|\s]`*(?!DEBUG).*\)
Wiktor Stribiżav:
Puedes utilizar
\blog\.(?:info|warn|error)\((?!\s*`DEBUG\b)[\w\W]*?\);
Vea la demostración de expresiones regulares .
detalles
\b
- un límite de palabralog\.
-log.
cuerdas(?:info|warn|error)
- o bieninfo
,warn
oerror
\(
- un(
carbón de leña(?!\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` como palabra completa[\w\W]*?
- cualquier 0 o más caracteres, el menor número posible\);
- una);
subcadena.
Prueba y ajustes: