use strict;
my $str = 'Mar 8 14:13:05 apce14 hdsem-worker [2016-03-08 06:13:03,320: INFO/Worker-1] Sending API request (https://webapps.homedepot.com/hde/V1/lead) - params={} - payload={\'type\': \'json\', \'inputData\': \'{"marketingOptIn": 0, "appointmentTime": "", "otherProductsInterest": "", "lName": "O Rivera", "addr2": "", "addr1": "912 SW 143rd St", "productCode": "17", "gradeCode": "KIT", "state": "FL", "branch": 49, "siebelNum": "", "referralCode": "0335", "appointmentWanted": 0, "appointmentDate": "", "city": "NEWBERRY", "zipCode": "32669", "storeRepID": "", "baseStore": 270, "referralStore": "", "fName": "Juan", "remarks": "", "eMail": "juanorivera@bellsouth.net", "scNumber": "", "wPhone": "", "hPhone": "3522146016"}\'} - js';
my $regex = qr/Worker-1] (?<JMessage>\D+\d)/p;
if ( $str =~ /$regex/ ) {
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