Skip to content

Instantly share code, notes, and snippets.

@greyivy
Created July 14, 2021 01:05
Show Gist options
  • Save greyivy/dacefb652877497d103afa4552b71405 to your computer and use it in GitHub Desktop.
Save greyivy/dacefb652877497d103afa4552b71405 to your computer and use it in GitHub Desktop.
Piglatinize code golf (w/ capitalization and punctuation)
z=/([\s-])/;module.exports=s=>s.split(z).map(x=>z.test(x)?x:(s=>([,b,w,v,c,a]=/^(\W*)(([aeiouAEIOU]?)([a-z]?)[\w]+)(\W*)$/.exec(s),f=w[1],v?`${b}${w}way${a}`:`${b}${f[`to${c?'Low':'Upp'}erCase`]()}${w.slice(2)}${w[0].toLowerCase()}ay${a}`))(x)).join('')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment