I want to capture a part of an XML string and replace a captured value with a new one.
I have the following code:
Regex regex = new Regex("<ns1:AcctId>(?<AcctId>.*?)</ns1:AcctId>");
Match match = regex.Match(Xml);
string AcctId = match.Groups["AcctId"].Value;
string IBANizedAcctId = IBANHelper.ConvertBBANToIBAN(AcctId);
newXml = Regex.Replace(oldXml, regex, IBANizedAcctId); //DOES NOT WORK!
So I want to capture the AcctId in the ns1:AcctId XML element. Then I want to replace this one with a new value by converting the BBAN to IBAN and replace the value. The first part works, but I do not know how to accomplish the last part (I did find an idea here, but I do not understand it).
I hope someone can help me out!


Xml = Regex.Replace(Xml, regexString, string.Format("$1{0}$3", IBANizedAcctId));where the regexString has three capturing groups:string regexDestAcctIntString = "(<ns1:AcctId>)(?<AcctId>.*?)(</ns1:AcctId>)";The$1and$3refer to respectively the first and third capturing group and replace the middle with the new value. 80% sure it works.