Replace all matches of regex with manipulation on specific capturing group

后端 未结 2 2022
终归单人心
终归单人心 2021-01-26 00:36

I have different Xml strings that can contain one or more parts in the following format:

47862656

The valu

2条回答
  •  猫巷女王i
    2021-01-26 00:49

    Apart from the usual don't use regex to manipulate XML.

    string regex = "(?<=).*?(?=)";
    Xml = Regex.Replace(Xml, regex, delegate(Match m) {
                               return IBANHelper.ConvertBBANToIBAN(m.Value);
                             });
    

    This uses positive look ahead and look behind so that the match is just the account number and then the overload to Regex.Replace the takes a match evaluator.

提交回复
热议问题