using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"AND[ ]+(\([ ]*\[\[[A-Z0-1_]+\]\][ ]+=[ ]+'[ ]*'[ ]+OR[ ]+[A-Z0-1_]+[ ]+=[ ]+\[\[[A-Z0-1_]+\]\][ ]*\)|\([ ]*[A-Z0-1_]+[ ]+=[ ]+\[\[[A-Z0-1_]+\]\][ ]+OR[ ]+\[\[[A-Z0-1_]+\]\][ ]+=[ ]+'[ ]*'[ ]*\))";
string input = @"SELECT
ZT1_CODIGO, ZT1_NOME, A3_NREDUZ, ZT1_EMAIL, ZT1_DEPART, ZT1_SENHA, ZT1_CODGRU, ZT2_NOME, ZT1_DDD, ZT1_DDI, ZT1_TEL, ZT1_LOGIN, SUBSTR(ZT3_CODENT,3,6) A3_COD
FROM TABSX2(ZT1) ZT1
LEFT JOIN TABSX2(ZT3) ZT3
ON ZT3.ZT3_ENTIDA = 'SA3' AND ZT1.ZT1_CODIGO = ZT3.ZT3_CODIGO AND ZT3.D_E_L_E_T_ <> '*'
LEFT JOIN TABSX2(SA3) SA3
ON SA3.A3_COD = SUBSTR(ZT3.ZT3_CODENT,3,6) AND SA3.D_E_L_E_T_ <> '*'
LEFT JOIN TABSX2(ZT2) ZT2
ON ZT2.ZT2_CODIGO = ZT1.ZT1_CODGRU AND ZT2.D_E_L_E_T_ <> '*'
WHERE ZT1.D_E_L_E_T_ <> '*' AND (ZT1_CODGRU = [[GRUPO]] OR [[GRUPO]] = '') AND ([[GRUPO]] = '' OR ZT1_CODGRU = [[GRUPO]] ) AND ZT1_CODGRU = [[GRUPO]]";
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