using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(<p>(?=<img\s.*?))(.*?)(</p>)";
string substitution = @"<figure class=""image"">\2</figure>";
string input = @"<p><img src=""/files/ffea8817-b5c4-406e-a7b2-3f6e52c69398.png"" style=""height:901px; width:797px"" /></p>
<p><img src=""/files/ffea8817-b5c4-406e-a7b2-3f6e52c69398.png"" style=""height:901px; width:797px"" /></p>
<p><img src=""/files/ffea8817-b5c4-406e-a7b2-3f6e52c69398.png"" style=""height:901px; width:797px"" /></p>
<p><img src=""/files/ffea8817-b5c4-406e-a7b2-3f6e52c69398.png"" style=""height:901px; width:797px"" /></p><p><img src=""/files/ffea8817-b5c4-406e-a7b2-3f6e52c69398.png"" style=""height:901px; width:797px"" /></p>
";
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