using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"[A-Z]+:span-[0-9]+:[a-z]+:[A-Z]+:(?!Connected)[a-zA-Z]+";
string input = @"message = 'OK - physical_ok:23/24 signal_up:23/24. Details: OK:span-1:ok:UP:Connected OK:span-2:ok:UP:Connected OK:span-3:ok:UP:Connected OK:span-4:ok:UP:Connected OK:span-5:ok:UP:Connected OK:span-6:ok:UP:Connected OK:span-7:ok:UP:Connected OK:span-8:ok:UP:Connected OK:span-9:ok:UP:Connected OK:span-10:ok:UP:Connected OK:span-11:alarmed:DOWN:Disconnected OK:span-12:ok:UP:Connected OK:span-13:ok:UP:Connected OK:span-14:ok:UP:Connected OK:span-15:ok:UP:Connected OK:span-16:ok:UP:Connected OK:span-17:ok:UP:Connected OK:span-18:ok:UP:Connected OK:span-19:ok:UP:Connected OK:span-20:ok:UP:Connected OK:span-21:ok:UP:Connected OK:span-22:ok:UP:Connected OK:span-23:ok:UP:Connected OK:span-24:ok:UP:Connected | physical_ok=23;24 signal_up=23;24
";
foreach (Match m in Regex.Matches(input, pattern))
{
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