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