且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

高级Regex.Replace处理

更新时间:2023-02-18 08:17:21

我同意能够在交换机中使用组名称会很好;不幸的是,Group对象没有Name属性(它的基类Capture也没有)所以你能做的***的是:



I agree it would be nice to be able to use the group name in the switch; unfortunately the Group object doesn't have a Name property (and neither does its base class Capture) so the best you'll be able to do is the following:

string ReplaceMatch(Match m)
    {
    if (m.Groups["BytesCompleted"].Success) ...
    else if (m.Groups["BytesRemaining"].Success) ...
    ...
    }