Comment by customguy
3 days ago
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.
TIL about [^], never seen that before. Apparently, it works like a dot but it also matches newlines.
I believe this is the regular syntax for a set of characters (between "[" and "]"), but the caret symbol ("^") is negation when used inside the set. Therefore, it is simply the negation of an empty set of characters.
Oh, me too. I’ve previously used [\s\S] for that.
Pretty interesting that you can carry comments over.
I wonder if anything cool can be done with it today. It's probably useless.