using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(.*?(?:@heroImageURL\s*=\s*""[^""]+"".*?){1}@heroImageURL\s*=\s"")[^""]+(?="")";
string substitution = @"$1http://www.google.com/1.jpg";
string input = @" IF @brandName == ""A"" THEN
set @heroImageURL = ""http://www.image.com/a9230239u230.jpg""
set @productImageURL = ""http://www.image.com/A29200923.jpg""
ELSEIF @brandName == ""B"" THEN
set @heroImageURL = ""http://www.image.com/b2389823u238.jpg""
set @productImageURL = ""http://www.image.com/B22392029.jpg""
ELSEIF @brandName == ""C"" THEN
set @heroImageURL = ""http://www.image.com/c23892389289.jpg""
set @productImageURL = ""http://www.image.com/C49309934.jpg""
ELSEIF @brandName == ""D"" THEN
set @heroImageURL = ""http://www.image.com/d23423892833.jpg""
set @productImageURL = ""http://www.image.com/D09349409.jpg""
ELSEIF @brandName == ""E"" THEN
set @heroImageURL = ""http://www.image.com/e22823889899.jpg""
set @productImageURL = ""http://www.image.com/E22092309.jpg""
ELSE
set @heroImageURL = ""http://www.image.com/e22823889899.jpg""
set @productImageURL = ""http://www.image.com/E22092309.jpg""
ENDIF";
RegexOptions options = RegexOptions.Singleline;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution, 1);
}
}
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