fork download
  1. <?php
  2.  
  3. function x($s){$r='preg_replace';$s=$r('/ +/',' ',$s);$s=$r(array('/ \^COMMA/','/ \^COLON/','/ \^SEMICOLON/','/ \^PERIOD/','/ \^BANG/','/\^DASH/','/ \^HYPHEN /','/ \^EMDASH /','/\^OPENQUOTE /','/ \^CLOSEQUOTE/'),array(',',':',';','.','!','-','-','--','"',',"'),$s);$s=$r('/(^\W*\w|([\.!]| ")\W+\w)/e','strtoupper("$0")',$s);$s=$r('/([,\.!]),/','\1',$s);$s=$r('/(\w)( "\w)/e','"$1,".strtoupper("$2")',$s);echo$s;}
  4.  
  5. echo x("once upon a time ^COMMA there was a horse ^PERIOD that horse cost me $50 ^PERIOD ^OPENQUOTE eat your stupid oats ^COMMA already ^BANG ^CLOSEQUOTE I told the horse ^PERIOD the horse neighed back ^OPENQUOTE no ^CLOSEQUOTE and died ^PERIOD I always hated that stupid horse ^DASH his name was Franklin ^HYPHEN James the III ^PERIOD I decided to go and buy a new animal ^EMDASH a cow ^EMDASH named Franklin ^HYPHEN James ^SEMICOLON however ^COMMA this time he was the first in his line, so his full name was simply Franklin ^HYPHEN James ^PERIOD That cow sucked ^PERIOD I wish I could have the talking horse named Ed ^PERIOD One time, I went to a circus and they had a banner that said ^COMMA ^OPENQUOTE COME SEE ED ^COLON THE TALKING HORSE ^BANG ^CLOSEQUOTE but I had no money so I did not get to see him ^PERIOD THE END ^PERIOD");
  6.  
  7.  
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Once upon a time, there was a horse. That horse cost me $50. "Eat your stupid oats, already!" I told the horse. The horse neighed back, "No," and died. I always hated that stupid horse - his name was Franklin-James the III. I decided to go and buy a new animal--a cow--named Franklin-James; however, this time he was the first in his line, so his full name was simply Franklin-James. That cow sucked. I wish I could have the talking horse named Ed. One time, I went to a circus and they had a banner that said, "COME SEE ED: THE TALKING HORSE!" But I had no money so I did not get to see him. THE END.