using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?=(\d{2}\/\d{2}\/\d{4}))(?=([^\n]+\n)+[^\n]*BNA\sCNTRS[^=\n]*\n)([^\n]+\n)+";
string input = @"*044*05/02/2013*14:24*
*1234*1*(Iw(1*0, M-00, R-10011002100310041
A/C
OPERATION OK
*044*05/02/2013*14:24*
*1234*1*(Iw(1*0, M-00, R-10011002100310041
A/C
*044*05/02/2013*14:24*
*1234*1*(Iw(1*0, M-00, R-10011002100310041
A/C
OPERATION OK
[0r(1)2[000p[040qe1w3h162*054*05/04/2013*14:27*
*1234*1*(Iw(1*0, M-00, R-10011002100310041
A/C
*055*05/04/2013*14:27*
*1234*1*(Iw(1*0, M-00, R-10011002100310041
A/C
OPERATION OK
[020t*057*05/04/2013*14:27*
[05p
BNA CNTRS
LAST CLEARED : 00/00/00 00:00
COUNT
ENCASHED 141
[0r(1)2[000p[040qe1w3h162*065*05/05/2013*14:30*
*1234*1*(Iw(1*0, M-00, R-10011002100310041
A/C
OPERATION OK
*071*05/06/2013*14:31*
*1234*1*(Iw(1*1, M-00, R-10011002100310041
A/C
CUSTOMER CANCEL
[020t*076*05/06/2013*14:32*
[05p
BNA CNTRS
LAST CLEARED : 05/04/13 14:28
COUNT
ENCASHED 11";
RegexOptions options = RegexOptions.Singleline;
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