use strict;
my $str = ' +883620946918182db5a277fc5e328fee3030ef79 src/dobot_cr_driver (8836209)
-8fc5c05835a246d7cb46952f748efec11fbf0075 src/onrobot_driver
b5704131f0e2964e4d051d5e6f6560917c2a1969 src/ros_camera
1ffdd69181389b14b7d6342f0c5bad3b45c5e32f src/ur_meta (1.1.5-315-g1ffdd69)
ec2beb65afd6be5373d1e21a86dd42a07e25b447 src/ur_official_driver (v2.0.0-4-gec2beb6)
883620946918182db5a277fc5e328fee3030ef79 src/dobot_cr_driver (8836209)
8fc5c05835a246d7cb46952f748efec11fbf0075 src/onrobot_driver (8fc5c05)
b5704131f0e2964e4d051d5e6f6560917c2a1969 src/ros_camera (heads/develop)
1ffdd69181389b14b7d6342f0c5bad3b45c5e32f src/ur_meta (1.1.5-315-g1ffdd69)
ec2beb65afd6be5373d1e21a86dd42a07e25b447 src/ur_official_driver (v2.0.0-4-gec2beb6)';
my $regex = qr/^[\s+-]?[^\s]+\s([^\s\n]+).*$/mp;
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