using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?<=SUBH2002078568)[\s\S]+?(?=SUBF2002078568)";
string input = @"HMT940040324
SUBH2002078568
2002078568{1:F01BANK MBI}{2:I940MAP}{4:
2002078568:20:20210420182417
2002078568:25:2002078568
2002078568:28C:00075
2002078568:60F:D210420IDR0,
2002078568:62F:D210420IDR0,
2002078568-}
SUBF2002078568
SUBH2003001298
2003001298{1:F01BANK MBI}{2:I940MAP}{4:
2003001298:20:20210420182417
2003001298:25:2003001298
2003001298:28C:00075
2003001298:60F:C210420IDR111520964,38
2003001298:62F:C210420IDR111520964,38
2003001298-}
SUBF2003001298
SUBH2002078568 // *Added this account from the top*
2002078568{1:F01BANK MBI}{2:I940MAP}{4:
2002078568:20:20210420182417
2002078568:25:2002078568
2002078568:28C:00075
2002078568:60F:D210420IDR0,
2002078568:62F:D210420IDR0,
2002078568-}
SUBF2002078568- // End
FMT9400000004";
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