fork download
  1. <?php
  2. $patterns = ["re", "get", "ER"];
  3. $string = "You are definitely getting\nbetter\ntoday";
  4. $alternations = implode('|', $patterns);
  5. $re = '\R?(?!(?<=\s)(?:'.$alternations.')(?=\s))\S*(?:'.$alternations.')\S*';
  6. $string = preg_replace('#'.$re.'#i', '', $string);
  7. $string = preg_replace('#\h{2,}#', ' ', $string);
  8. echo $string;
Success #stdin #stdout 0.03s 23788KB
stdin
Standard input is empty
stdout
You definitely 
today