简体   繁体   English

通配符(正则表达式?)搜索以关闭PHP中的行(Notepad ++?)

[英]Wildcard (regex?) search to close up lines in PHP (Notepad++?)

I have a three line code block, hundreds are scattered throughout one file, here's a representative example: 我有一个三行代码块,数百个文件散布在一个文件中,这是一个典型示例:

if(DEBUG) {
  $misc->Debug("Here is a debug message");
}

I want to collapse these lines, to result in: 我想折叠这些行,以得到:

if(DEBUG) {$misc->Debug("Here is a debug message");}

Any program will do, but I figured Notepad++ might be simplest? 任何程序都可以,但是我认为Notepad ++可能是最简单的?

Any assistance much appreciated! 任何帮助,不胜感激!

You can use the following regex: 您可以使用以下正则表达式:

if\(DEBUG\)\s*\{\s*([^\r\n]+)\s*\}

with subsitution to 替换为

IF\(DEBUG\){ $1 }

In Notepad++ use the following regex to find those lines: 在记事本++中,使用以下正则表达式查找这些行:

Find what : if\\s*\\(DEBUG\\)\\s*\\{\\s*(\\$misc->Debug\\("[^"]+"\\);)\\s*\\} 查找内容: if\\s*\\(DEBUG\\)\\s*\\{\\s*(\\$misc->Debug\\("[^"]+"\\);)\\s*\\}

Replace with : if\\(DEBUG\\) {$1} 替换为: if\\(DEBUG\\) {$1}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM