logoalt Hacker News

customguy • today at 11:33 AM • 2 replies • view on HN

Yesterday I was re-using some shaders I had written a long time ago, and here's what I used to do multiline strings before the glorious backtick arrived on the scene...

    (function () {/*
      my awesome shader code
    */}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1]
... I can't call it sexy, but I also can't deny I felt a mixture of fear and arousal when I saw that.

Replies

annex-winged-cr • today at 12:28 PM

TIL about [^], never seen that before. Apparently, it works like a dot but it also matches newlines.

➕ show 2 replies
h43z • today at 12:21 PM

Pretty interesting that you can carry comments over.

    (x=>/*this is a comment*/1) + 1
    "x=>/*this is a comment*/11"
I wonder if anything cool can be done with it today. It's probably useless.