I am trying to replace multiple values in a string. Because of framework constraints I need to use Regex. I have looked at this solution to loop over captures and this solution to replace multiple captures I am trying to replace multiple iterations of a group that depend on some other group.
For example, in the string
WfTarget[...] Id:28 [...] Documents [...] Id:22 [...] Id: 30
I am trying to extract the numbers 22 and 30.
Using the following Regex, I was able to extract the latest Id, and have multiple captures:
(?<start>( WfTarget))(?<grouper>( Id: (?<Wanted>([\d]+))[^ ]*)*)
With this, I am able to write a replacement string like ${grouper}
and get all the iterations, but including the ID. Once I try, with wanted, I only get the last result
The problem with looping over the captures, is that this is a generic framework, and there is no way of saying on which group the looping must happen. Furthermore, the replacement string might have multiple groups to get things from. Resulting in extra non-wanted values
Edit
Input:
"WfTarget":"Status": "Active","Id": 2134,"StatusDisplay": "Version": 2, [...]"Documents": [ "Index": 0, "Id": 95, "Version": 0, "Index": 1, "Id": 42, [...]
Expected Output:
95,42