using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(Sensor #0 -> (?P<EXT>\d+[.]\d+)(?:.*?Sensor #2 -> )(?P<INT>\d+[.]\d+)(?:.*?)(?P<DATE>\d{4}\/\d{2}\/\d{2}\s+\d{2}:\d{2}:\d{2}))";
string input = @"system tmp gettemp 0
Sensor #0 -> 69.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 87.81
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:50system tmp gettemp 0
Sensor #0 -> 69.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 88.110
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:51system tmp gettemp 0
Sensor #0 -> 69.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 88.206
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:52system tmp gettemp 0
Sensor #0 -> 69.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 87.176
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:53system tmp gettemp 0
Sensor #0 -> 69.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 88.110
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:54system tmp gettemp 0
Sensor #0 -> 69.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 88.110
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:55system tmp gettemp 0
Sensor #0 -> 69.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 87.176
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:56system tmp gettemp 0
Sensor #0 -> 69.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 87.81
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:57system tmp gettemp 0
Sensor #0 -> 68.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 88.15
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:58system tmp gettemp 0
Sensor #0 -> 68.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 88.15
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:59system tmp gettemp 0
Sensor #0 -> 68.0
OK
dbg_cpu0> 2016/11/23 11:05:002016/11/23 11:05:012016/11/23";
RegexOptions options = RegexOptions.Singleline | 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