use strict;
my $str = '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';
my $regex = qr/^(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}))/smp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
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 Perl, please visit: http://perldoc.perl.org/perlre.html