I have an xml
file and I wanted to search the file using the regular expression.
My used regular expression:
(? <= <Name> Description <\ / Name> <Value>). *? (? = <\ / Value>)
And replace the expressions found by a left(expression, 15)
. There are situations where the string is too long and you need to truncate to left 15.
Example:
https://regex101.com/r/Etfpol/3
The text found is:
- Solution changed from
- Resolved Time changed
- Updated By changed from
I want to replace:
- Solution change
- Resolved Time c
- Updated By chan
My tried Code:
System.IO.StreamReader file = new System.IO.StreamReader(Dts.Connections["xmlfile.xml"].ConnectionString);
Dts.Variables["varXML"].Value = file.ReadLine();
String teste = Dts.Variables["varXML"].Value.ToString();
string pattern = @"(?<=<Name>Description<\/Name><Value>).*?(?=<\/Value>)";
string result = Regex.Replace(teste, pattern, ); Dts.Variables["varXML"].Value = result;
Thanks.