Skip to main content
added 43 characters in body
Source Link
tsh
  • 35.6k
  • 2
  • 34
  • 129

JavaScript (Node.js), 8280 bytes

s=>(p=s.replace(/(?:if\(if.(.*?)\)|;else|;.*? )(.=)?/g,(_,t,v)=>(V=v||V,t)?t+'?':':'),V+p)

Try it online!Try it online!

Thanks to Kevin Cruijssen, 2 bytes saved.

JavaScript (Node.js), 82 bytes

s=>(p=s.replace(/(?:if\((.*?)\)|;else )(.=)?/g,(_,t,v)=>(V=v||V,t)?t+'?':':'),V+p)

Try it online!

JavaScript (Node.js), 80 bytes

s=>(p=s.replace(/(?:if.(.*?)\)|;.*? )(.=)?/g,(_,t,v)=>(V=v||V,t)?t+'?':':'),V+p)

Try it online!

Thanks to Kevin Cruijssen, 2 bytes saved.

deleted 3 characters in body
Source Link
tsh
  • 35.6k
  • 2
  • 34
  • 129

JavaScript (Node.js), 8382 bytes

s=>(p=s.replace(/(?:if\((.*?)\)|;else )(.=)?/g,(_,t,v)=>(v?V=v:0V=v||V,t)?t+'?':':'),V+p)

Try it online!Try it online!

JavaScript (Node.js), 83 bytes

s=>(p=s.replace(/(?:if\((.*?)\)|;else )(.=)?/g,(_,t,v)=>(v?V=v:0,t)?t+'?':':'),V+p)

Try it online!

JavaScript (Node.js), 82 bytes

s=>(p=s.replace(/(?:if\((.*?)\)|;else )(.=)?/g,(_,t,v)=>(V=v||V,t)?t+'?':':'),V+p)

Try it online!

Source Link
tsh
  • 35.6k
  • 2
  • 34
  • 129

JavaScript (Node.js), 83 bytes

s=>(p=s.replace(/(?:if\((.*?)\)|;else )(.=)?/g,(_,t,v)=>(v?V=v:0,t)?t+'?':':'),V+p)

Try it online!