If the string does not contain GYN, the regex will not match. Everything except null (which you are going to replace) is in a capture group.
Replace with:
$1$2$3GYN$4
That’s the first capture group, the second capture group, the third capture group, GYN (which will replace the null, which is not captured), the fourth capture group.
Note that this assumes that the strings to test are each on a single line, no line breaks
No, you understand, it’s just the substitution syntax I think.
In JS, it’s a dollar sign followed by the index (from 1) of the capturing group - so $1$2 is the first two, $2$1 would swap them and so on.
But $ already has meaning in Perl, so I don’t think it can be that – I’m not familiar with Perl at all, so not much help here at the minute, I’ll have a Google around
Edit: it is $
It’s because you’re not replacing the whole string I think, but my lack of Perl knowledge means I’m not sure what it should look like
Basically, it needs to be like
$subst = /$1$2$3GYN$4/
What’s between the / there is what the substitution should be, but I have no idea if using / is correct there.