using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?=(?=(?'a'[\s\S]*))(?<!'b'<p\b[^>][\s\S]color[\s\S]:[\s\S]black[^>][\s\S]>[\s\S]<span\b[^>][\s\S]>[\s\S])(?<!<span\b[^>][\s\S]color[\s\S]:[\s\S]black[^>][\s\S]>[\s\S])_(?=\k'a'\z)|(?<=(?=x^|(?<!&b))[\s\S]))<code\s*style=""background-color:\s*transparent;"">";
string input = @"<html>
<p style=""font-family: "verdana"; font-size: 18px; color: black; line-height: 18px; text-align: justify; font-style: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; background-color: cyan;""><span style=""font-size: 13.5pt; font-family: "Verdana","sans-serif";""><code style=""background-color: transparent;""><b>some text here</b></code></span></p>
<span><span style=""font-size: 13.5pt; font-family: "Verdana","sans-serif"; background-color: cyan;""><code style=""background-color: transparent;""><b>some text here</b></code></span>
<code style=""background-color: transparent;"">
<p style=""font-family: "verdana"; font-size: 18px; color: cyan; line-height: 18px; text-align: justify; font-style: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; background-color: cyan;""><span style=""color: black; font-size: 13.5pt; font-family: "Verdana","sans-serif";""><code style=""background-color: transparent;""><b>some text here</b></code></span></p>
<span><span style=""font-size: 13.5pt; font-family: "Verdana","sans-serif"; background-color: cyan;""><code style=""background-color: transparent;""><b>some text here</b></code></span>
<p style=""font-family: "verdana"; font-size: 18px; color: cyan; line-height: 18px; text-align: justify; font-style: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; background-color: navy;""><span style=""font-size: 13.5pt; font-family: "Verdana","sans-serif";""><code style=""background-color: transparent;""><b>some text here</b></code></span></p>
</html>";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
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