Skip to main content
added 46 characters in body
Source Link
Shieru Asakoto
  • 6.3k
  • 16
  • 40

JavaScript (Node.js), 102 129 110110 106 bytes

s=>s[p="replace"](s/(\d+)( \w*[A-Z])/gi,f=g=(_,a,b)=>b.repeat(a))=>s[p="replace"](/(\d+)( \w*[A-Z])/gi,f)[p](/(\d+)(.)/g,fg)[p](/ +/g,(_,i)=>i?" ":"")

Try it online!Try it online!

Thanks for @Arnauld for -4 bytes.

JavaScript (Node.js), 102 129 110 bytes

(s,f=(_,a,b)=>b.repeat(a))=>s[p="replace"](/(\d+)( \w*[A-Z])/gi,f)[p](/(\d+)(.)/g,f)[p](/ +/g,(_,i)=>i?" ":"")

Try it online!

JavaScript (Node.js), 102 129 110 106 bytes

s=>s[p="replace"](/(\d+)( \w*[A-Z])/gi,g=(_,a,b)=>b.repeat(a))[p](/(\d+)(.)/g,g)[p](/ +/g,(_,i)=>i?" ":"")

Try it online!

Thanks for @Arnauld for -4 bytes.

amend
Source Link
Shieru Asakoto
  • 6.3k
  • 16
  • 40

JavaScript (Node.js), 102 129 111110 bytes

(s,f=(_,a,b)=>b.repeat(a))=>s[p="replace"](/(\d+)( \w*[A-Z])/gi,f)[p](/(\d+)(\w.)/g,f)[p](/ +/g,(_,i)=>i?" ":"")

Try it online!Try it online!

JavaScript (Node.js), 102 129 111 bytes

(s,f=(_,a,b)=>b.repeat(a))=>s[p="replace"](/(\d+)( \w*[A-Z])/gi,f)[p](/(\d+)(\w)/g,f)[p](/ +/g,(_,i)=>i?" ":"")

Try it online!

JavaScript (Node.js), 102 129 110 bytes

(s,f=(_,a,b)=>b.repeat(a))=>s[p="replace"](/(\d+)( \w*[A-Z])/gi,f)[p](/(\d+)(.)/g,f)[p](/ +/g,(_,i)=>i?" ":"")

Try it online!

golfed
Source Link
Shieru Asakoto
  • 6.3k
  • 16
  • 40

JavaScript (Node.js), 102102 129 111 bytes

s=>s.replace(/(\d+ )?(\d+)( ?.)/gs,f=(_,a,b,c)=>(x=c=>b.repeat(b),a?`))=>s[p="replace"](/(\d+)( ${x}`.repeat\w*[A-Z])/gi,f)[p](a/(\d+):x(\w)/g,f).replace[p](/ +/g,(_,i)=>i?" ":"")

Try it online!Try it online!

JavaScript (Node.js), 102 bytes

s=>s.replace(/(\d+ )?(\d+)( ?.)/g,(_,a,b,c)=>(x=c.repeat(b),a?` ${x}`.repeat(a):x)).replace(/ +/g," ")

Try it online!

JavaScript (Node.js), 102 129 111 bytes

(s,f=(_,a,b)=>b.repeat(a))=>s[p="replace"](/(\d+)( \w*[A-Z])/gi,f)[p](/(\d+)(\w)/g,f)[p](/ +/g,(_,i)=>i?" ":"")

Try it online!

Source Link
Shieru Asakoto
  • 6.3k
  • 16
  • 40
Loading