fork(5) download
  1. <?php
  2.  
  3. $help = 'This endline should not be removed,
  4. but this one really should "as it\'s within the double quotation,
  5. like this", and this is another line not to be removed either,
  6. " but this definitely a candidate for
  7. removing" filler
  8. "filler filler filler
  9. filler"';
  10.  
  11. echo preg_replace('#\\n(?=[^"]*"[^"]*(?:"[^"]*"[^"]*)*$)#' , ' ', $help);
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
This endline should not be removed,
but this one really should "as it's within the double quotation, like this", and this is another line not to be removed either,
" but this definitely a candidate for removing" filler
"filler filler filler  filler"