the original said reggae but i misread it as regex and got this idea lol

original comic artist: thisstupidtwink@insta

  • Dæmon S.@catodon.rocks
    link
    fedilink
    arrow-up
    14
    ·
    1 day ago

    !onehundredninetysix@lemmy.blahaj.zone
    There’s something else: the backslash followed by a positive natural number means a reference to the nth capture group, so:

    "truthfultemporarily".match(/(t)(r)(u)\1hf\3(l)\1empo\2a\2i\4y/)

    …as esoteric as it may sound, will match your Lemmy username, because the \1 will correctly match the first capture group which is t, \2 will match the second capture group which is r, and so on so forth… Oh, and it works beyond .replace contexts, during .match as well.

    Source: I just learned through this very meme and, from now on, I’ll likely use this feature whenever I have to use RegExp because I love coding cryptic one-liners just for the sake of it.

    Screenshot of DevTools illustrating the working of the aforementioned snippet, with its output correctly matching the string.

    • Bubs@lemmy.zip
      link
      fedilink
      English
      arrow-up
      7
      ·
      1 day ago

      Heheh

      I love bringing out all the nerds to talk on random niche topics :3

      • Zoop@beehaw.org
        link
        fedilink
        English
        arrow-up
        2
        ·
        13 hours ago

        Right!? I love what you’ve caused here. Especially since I was wondering the same thing myself. I’m really enjoying these neat, informative replies! I <3 NERDS!