using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?:\G(?!\A)|<img)
(?s:.+?\bsrc=['""])\K
https?://.+?(?=/wp-content/)";
string substitution = @"http://someotherdomain.com";
string input = @"<img
src=""https://www.example.com/de/wp-content/uploads/sites/1/2017/03/image.jpg""
data-srcset=""
https://www.example.com/de/wp-content/uploads/sites/1/2017/03/img1.jpg 507w,
https://www.example.com/de/wp-content/uploads/sites/1/2017/03/img2.jpg 780w,
https://www.example.com/de/wp-content/uploads/sites/74/2017/03/img3.jpg 950w""
data-sizes=""
(min-width: 80em) calc(0.5 * (100vw - (100vw- 57em))),
(min-width: 48em) calc(0.5 * (100vw - 5em)),
calc(100vw - 1em)""
alt=""image"" class=""lazyload"">
<img
src=""https://www.example.com/de/wp-content/uploads/sites/1/2017/03/image.jpg""
data-srcset=""
https://www.example.com/de/wp-content/uploads/sites/1/2017/03/img1.jpg 507w,
https://www.example.com/de/wp-content/uploads/sites/1/2017/03/img2.jpg 780w,
https://www.example.com/de/wp-content/uploads/sites/74/2017/03/img3.jpg 950w""
data-sizes=""
(min-width: 80em) calc(0.5 * (100vw - (100vw- 57em))),
(min-width: 48em) calc(0.5 * (100vw - 5em)),
calc(100vw - 1em)""
alt=""image"" class=""lazyload"">";
RegexOptions options = RegexOptions.IgnorePatternWhitespace;
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