C# and Regex - Unrecognized grouping construct

前端 未结 1 424
后悔当初
后悔当初 2021-01-13 12:35

Currently working on my thesis for a client/server app. I\'ve run into a snag were the server receives information like this:

ProToCooL,unknown|DESKTOP-29COF         


        
相关标签:
1条回答
  • 2021-01-13 13:15

    .NET regex does not support recursion. The regex you are using (\(((?:[^()]|(?R))+)\)) is for PCRE, and you can use it with PCRE.NET library in a C# app.

    As an alternative, you can use a .NET regex to match balanced parentheses:

    \(((?>[^()]+|\((?<n>)|\)(?<-n>))+(?(n)(?!)))\)
    

    See regex demo.

    It returns all those 12 matches as the PCRE regex.

    0 讨论(0)
提交回复
热议问题