fork download
  1. <?php
  2.  
  3. $infinite = "/^([a-z]|[0-9]| |,|'|\.|!|\?)*$/i"; // Allows infinite repetition
  4. $fourk = "/^[a-z0-9 ,'.!?]{1,4000}$/i"; // Limits repetition to 4000
  5.  
  6. $string = "I like apples.";
  7.  
  8. if ( preg_match($infinite, $string) ){
  9.  
  10. echo "Passed infinite repetition. \n";
  11. }
  12.  
  13. if ( preg_match($fourk, $string) ){
  14.  
  15. echo "Passed maximum repetition of 4000. \n";
  16. }
  17.  
  18. ?>
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
Passed infinite repetition. 
Passed maximum repetition of 4000.