using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(<p value=""id"">(?=1445).+\R.+<p value=""IP"">)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(.+)";
string substitution = @"\110.25.30.19\3";
string input = @" <list name=""ItemList"">
<item>
<p value=""id"">1445</p>
<p value=""IP"">10.25.30.19</p>
<p value=""Prflen"">26</p>
</item>
<list name=""ItemList"">
<item>
<p value=""id"">1499</p>
<p value=""IP"">10.40.50.53</p>
<p value=""Prflen"">26</p>
</item>
<list name=""ItemList"">
<item>
<p value=""id"">1445</p>
<p value=""IP"">10.45.70.19</p>
<p value=""Prflen"">26</p>
</item>
<list name=""ItemList"">
<item>
<p value=""id"">1446</p>
<p value=""IP"">10.77.90.55</p>
<p value=""Prflen"">26</p>
</item>";
RegexOptions options = RegexOptions.Multiline;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx