简体   繁体   中英

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?

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*\\}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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