firasdib/Regex101

Substitution: Insert capture group and all of its Captures/subgroups (.NET)

Closed this issue · 3 comments

w4po commented

Feature

In .NET you can have captures/sub-captures, consider the following example:

Pattern:

: (?:([a-f0-9]{2}) )+

Content:

spaced: 01 00 00 00 1c c6 f5 a9 1a 12 7f a2 06 ae 56 ec 35 3c e0 55 c7 34
none: 1cc6f5380055c73471a4495410

You will get multiple group 1 like 1.1, 1.2, 1.3, etc...

I want to be able to insert the capture group and all of its captures/subgroups

using the following substitution pattern:

: $1

the desired behavior:

spaced: 010000001cc6f5a91a127fa206ae56ec353ce055c734
none: 1cc6f5380055c73471a4495410

current behavior:

spaced: c734
none: 1cc6f5380055c73471a4495410

It would be nice to be able to also use a specific sub-group like for example: $1.3

As far as I know, this isn't possible in .NET. If there is native language support for it, I could add it. Otherwise, you'll have to figure this out on your own when writing your .NET code.

w4po commented

All I am asking is if you can add a new substituting token,
Something like $a1 that has all the values of the subgroups of Group 1
And another for a specific sub-group like $1'4 for the value of group 1.4,
I am terrible at naming things but I think you've got the idea

Screenshot 2024-08-11 115034