use strict;
my $str = 'processors => {"models"=>["AMD Opteron(tm) Processor 6172", "AMD Opteron(tm) Processor 6172", "AMD Opteron(tm) Processor 6172", "AMD Opteron(tm) Processor 6172"], "count"=>4, "physicalcount"=>2}
productname => VMware Virtual Platform
ps => ps -ef
puppetversion => 3.6.2
rubysitedir => /usr/local/brs/harmony-puppet/lib/ruby/site_ruby/2.1.0
rubyversion => 2.1.2
sshecdsakey => AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNDUmg8FQGCO/r/VGABUPwBqT8zTwzXwZCjTdBC6cXj1Mo5ypxuqO1Qtwg9uQagcS5eLNbv+SxHotpzYSXZ1R8g=
sshfp_dsa => SSHFP 2 1 42ffbd293f1501c0718b2b7b3852542329da1758
SSHFP 2 2 eb52d78a34bdadecc41b38366a5580c923bbb6cd0b81cec76de6379ce4251439
sshfp_ecdsa => SSHFP 3 1 d41abd2e3aff846b4efb59dbc8e4803875d33130
SSHFP 3 2 ae77a20a66859976e06efb7d6dd0819db4f9e9d93bc55da52a4bffff6acb1baa
sshfp_rsa => SSHFP 1 1 d3f14587683138e6d10cacba92fa34364ed5d326
SSHFP 1 2 132856925e056d02767e6c6ca4015ed21ac4c6eddb727f7c69e5edecb8806884
sshrsakey => AAAAB3NzaC1yc2EAAAADAQABAAABAQDzcJ6158aIkY161vcDH6WKNgKAeUsxrHh+HJH9IEistcV2TUJSdHtG/p5peI+cTa0EhabbNw8ToUU3ZWYmiTmxxuZzxggAxCx6xhWNDgC/492QnouxHnqjxwpFyIYnLpdbaMRV/6t9iE7v09Gfb31TS3/DbAUh5yla1OOeHbxJQ/eUOUYgy7/6eFL43+R9SfiuP11VRK8r325mCOFaPqw8VuNeGul/rMnccBCbuFvgmQnfOo/ldwrfOL2W4qAvfE0bKyG13WrDSlauo+CFtYqDK08hCItjrbVKgVrOzLCuKGzKFuqOgF3u8Q1je23qu7eUmF7lZPYVWSEpkh0xlR0p
swapfree => 1.45 GB
swapfree_mb => 1482.82
swapsize => 1.46 GB
swapsize_mb => 1497.00
system_uptime => {"seconds"=>6034301, "hours"=>1676, "days"=>69, "uptime"=>"69 days"}
timezone => PDT';
my $regex = qr/^(\w+) => (.*?)(?=(?:\s^\w+ =>|\z))/msp;
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