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