Good afternoon @Pathler !
There are numerous ways to achieve what you want, I’ll show you below one of them which is graphic, and a 2nd one which is more efficient:
- Disclaimer: Option 1 it’s not the only way, neither the best! In my opinion, is the most visual one to understand the steps.
After you’ve found all the substrings based on the 3 digits, lets see the output:
We will remove the empty value with the following:
var_listOutput = var_listOutput.Where(function (x) Not String.IsNullOrEmpty(x)).Distinct().ToList()
The output here will be the following:
As you can see, the empty value has disappeared, and all we have left is to group them, every 2 values, meaning List(0) + List(1), List(2) + List(3)…
We can do this with a Do While + another List, which we will iterate every 2 items:
So every iteration, we’re Creating a new list, with the items grouped every 2 values
Option 2 (better and more efficient)
- Improvement on the Regex function:
system.Text.RegularExpressions.Regex.Split(var_initText,"(.+?(?=\d{3}))").ToList
Combined with the “Remove empty values” Linq from above, you have your output!
Both codes attached here:
RegexDemo.zip (59.8 KB)