using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"<img([^>]*)src=""[(([^:""]*)({png|gif|jpg|jpeg}))]""";
string substitution = @"<img \2";
string input = @"<!DOCTYPE html>
<html>
<body>
<img src=""smiley.gif"" alt=""Smiley face"" height=""42"" width=""42"" style=""float:right"">
<p>Insert an image from another folder:</p>
<img src=""/images/stickman.gif"" alt=""Stickman"" width=""24"" height=""39"">
<p style=""float:left"">Insert an image from a web site:</p>
<img style=""color:green; float:right;"" src=""http://www.w3schools.com/images/lamp.gif"" alt=""Lamp"" width=""15"" height=""15"">
</body>
</html>
";
RegexOptions options = RegexOptions.IgnoreCase | 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