In the example below, I'm trying to simply find all the date values in an XML
document (the XML is a string in this example) and then add an upper case Z
between the last digit and the closing '<' character. My strSearch is ok,
but my strReplace doesn't seem to do anything.
Anyone know how to get my desired result?
Thanks,
Paul
-------------------------------------------------------------
string saTests1 =
"<periodOfReport>2006-08-08</periodOfReport><transactionDate><value>2006-07-01</value></transactionDate><signatureDate>2006-09-01</signatureDate>";
string strSearch =
">(?<Year>(?:\\d{4}))-(?<Month>\\d{2})-(?<Day>\\d{2})<";
string strReplace = ">${year}-${month}-${day}Z<";
Regex.Replace( saTests1, strSearch, strReplace );
Desired output:
"<periodOfReport>2006-08-08Z</periodOfReport><transactionDate><value>2006-07-01Z</value></transactionDate><signatureDate>2006-09-01Z</signatureDate>";