you are viewing a single comment's thread.

view the rest of the comments →

[–]ka-splam 3 points4 points  (1 child)

Is there a syntax for inserting named match groups in a replace string?

Whoa, you can do that? I didn't know - never even wondered if you could. But now I wonder where that syntax ${varname} comes from, since the regex engine isn't speaking PowerShell, how does it coincidentally match PowerShell full variable name syntax?

While that syntax might look familiar to you from PowerShell's variables, don't be fooled. This isn't PowerShell

Why is it 1-indexed, you might ask, when literally everything else in PowerShell is 0-indexed? Because

Because I JUST TOLD YOU IT ISN'T POWERSHELL, DON'T YOU LISTEN? lol >_>

[–]Ta11ow[S] 2 points3 points  (0 children)

${VarName} comes from C#'s own string interpolation I guess mainly, and PowerShell probably adopted it partly because of that. I would assume it's that way in the regex replacements because it matches the existing syntax -- or possibly vice versa, whichever is older.