use strict;
my $str = '002446fffd003274.2:
Label: Back Door Lock
Manufacturer: Kwikset
Model: SMARTCODE_DEADBOLT_5
Firmware version: 0x3071cb06
Hardware version: 3
User Properties:
NearEndRssi: -41
NearEndLqi: 243
label: Back Door Lock
deadboltJammed: false
Battery Operated: True
Voltage: 5.8V
FE radio: -67/254
NE radio: -41/243
Date added: Thu Oct 27 08:02:42 CDT 2016
Date of last communication: Mon Feb 13 14:15:14 CST 2017
In Communication Failure: false
In firmware upgrade failure: false
Firmware upgrade available: false
Is Locked: true
Max Users: 30
Operation Mode: normal';
my $regex = qr/Manufacturer:\s(?<Manufacturer>.*)/p;
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