Visual Studioのコードでの正規表現でキャリッジリターン改行で文字列を置き換え

Yellow75:

Visual Studioのコードでは、私はすべてのプロジェクトファイルには、すべての命令がと等しくないlog.info、交換したいと思います:

log.info(
                `DEBUG other strings...
);

何も(私はすべてのファイルでそれらを削除したいです)。例えば、このlog.infoを削除する必要があります。

log.info(
                `remove this instruction!!!
);

ではなく、この(それはDEBUGが最初の単語を持っていました):

log.info(
                `DEBUG other strings...
);

注意し、log.infoは()は、例えば、単一の行にも次のようになります。

log.info(`remove this instruction!!!);<br>
log.info(`DEBUG other strings...);<br>

私は結果なしで、これを試してみました:

log.(info|warn|error)\([\n|\s]`*(?!DEBUG).*\)
Wiktor第Stribiżav:

あなたは使用することができます

\blog\.(?:info|warn|error)\((?!\s*`DEBUG\b)[\w\W]*?\);

参照してください。正規表現のデモを

細部

  • \b - ワード境界
  • log\.- log.文字列
  • (?:info|warn|error)-のいずれかinfowarnまたはerror
  • \(- (文字
  • (?!\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`
  • [\w\W]*? - 任意の0個以上の文字、できるだけ少ないなど
  • \);- );ストリング。

テスト&設定:

ここでは、画像の説明を入力します。

おすすめ

転載: http://10.200.1.11:23101/article/api/json?id=400103&siteId=1