!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:
…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.
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!
!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
\1will correctly match the first capture group which ist,\2will match the second capture group which isr, and so on so forth… Oh, and it works beyond.replacecontexts, during.matchas 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.
Heheh
I love bringing out all the nerds to talk on random niche topics :3
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!