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"

alert(function(c){return c.replace(/\^((COMMA)|(SEMICOLON)|(COLON)|(PERIOD)|(BANG)|(DASH)|(HYPHEN)|(EMDASH)|(OPENQUOTE)|(CLOSEQUOTE))/g,((x,_,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q)=>a?",":b?";":c?":":d?".":e?"!":f?"-":g?"-h-":h?"-e-":i?' "':'" ')).replace(/\s+\./g,".").replace(/\s+\!/g,"!").replace(/\s+\,/g,",").replace(/\s+\;/g,";").replace(/\s+\:/g,":").replace(/\s\-\h\-\s/g,"-").replace(/[^!,"'.]\"\s/g,'"').replace(/\s+\-\e-\s+/g,"--").replace(/.+?[\.\?\!](\s+|$)/g,function(b){return b.charAt(0).toUpperCase()+ b.substr(1)}).replace(/\"[a-z]/g,function(b){return b.charAt(0)+b.charAt(1).toUpperCase()})}(a))