using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(<img.*?src="")((?:\w+\/)+?)([\w-]+\.(?:jpg|jpeg|png|gif))""";
string substitution = @"$1{#CDNPath#}img/$3""";
string input = @"<img src=""index_files/bottle2.jpg"" name=""product ds Grodsdwth"" class=""pullleft"">
<img title="" src=""index_files/ss-button.png"" class=""step-btn"" alt=""></a>
<img src=""index_files/a/bottle2.jpg"" name=""product ds Grodsdwth"" class=""pullleft"">";
Regex regex = new Regex(pattern);
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