JSFiddle - React, Tailwind, and code Playground
JavaScript
var a = "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"
R="replace",C="charAt",U="toUpperCase";alert(a[R](/\^((COMMA)|(SEMICOLON)|(COLON)|(PERIOD)|(BANG)|(DASH)|(HYPHEN)|(EMDASH)|(OPENQUOTE)|(CLOSEQUOTE))/g,((m,_,a,b,c,d,e,f,g,h,i,j)=>a?",":b?";":c?":":d?".":e?"!":f?"-":g?"-h-":h?"-e-":i?' "':'" '))[R](/\s((\.)|(\!)|(\,)|(\;)|(\:)|(\-\h\-\s)|(\-\e\-\s))/g,((k,l,v,n,o,p,q,r,s)=>v?".":n?"!":o?",":p?";":q?":":r?"-":"--"))[R](/[^!,"'.]\"\s/g,'"')[R](/.+?[\.\?\!](\s|$)/g,(t=>t[C](0)[U]()+t.substr(1)))[R](/\"[a-z]/g,(u=>u[C](0)+u[C](1)[U]())))