using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^[LNSE] .*(?:\n(?![LNSE] ).*)?";
string input = @"L 065 00 24329 12313 244.0.15.55 252.9.11.90 02/25 08:05 00:00:44 0000 0000
N 066 00 23442 T000185 262.1.00.09 02/25 08:05 00:00:02 A 16630
& 0000 0000
S 067 00 00984 T000134 02/25 08:06 00:00:02 A 61445
& 0000 0000
S 068 00 T000002 29536 02/25 08:05 00:00:36
& 0000 0000 1234567890XXXXXX
E 069 00 T000002 T000185 02/25 08:06 00:00:00
& 0000 0000 1234567890XXXXXX
L 065 00 24329 12313 244.0.15.55 252.9.11.90 02/25 08:05 00:00:44 0000 0000 ";
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