firasdib / Regex101

This repository is currently only used for issue tracking for www.regex101.com
3.26k stars 199 forks source link

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

Closed w4po closed 1 month ago

w4po commented 3 months ago

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

firasdib commented 1 month ago

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 1 month ago

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

firasdib commented 1 month ago

I am simply using the built-in features of .NET. I don’t create anything additional. Vänliga hälsningar / Best regards,Firas DibOn 11 Aug 2024, at 11:00, AbdAlrahman Ghanem @.***> wrote: 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.png (view on web)

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you modified the open/close state.Message ID: @.***>