Hi,Celebrimbor-4858
You can use Matches() to get the array instead and change the Regex as:
var x1 = System.Text.RegularExpressions.Regex.Matches("123456", @"(\G.{2})");
Matches is used to search an input string for all occurrences of a regular expression and returns all the matches.
Regex.Matches
Result:
.net 5.0 has many improvement about Regex, you can check this link:
regex-performance-improvements-in-net-5
Best Regards,
Jerry Cai
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.