.net core System.Text.RegularExpressions.Regex.Split

Celebrimbor 1 Reputation point
2021-01-06T03:13:08.603+00:00

in the .net core 3.1
53868-image.png

in the .net core 5.0

53866-image.png

.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,135 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jerry Cai-MSFT 986 Reputation points
    2021-01-07T05:53:57.257+00:00

    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:
    54230-1.png

    .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.

    0 comments No comments