use strict;
my $str = ' "Title: Y"
"Method: Mass-loaded (1.500 grams)"
"DCR mode: Measure (-0.07 ohms)"
"Area (Sd): 12.88 sq cm"
"QC-limits file: "
"Last setup file: C:\\MLS\\SPO-W.SET modified "
"Series resistance: 75.00 ohms"
"Stimulus level: 4.08 volts"
"SPLref reference impedance: NONE"
"Large units (volume = liters, mass = grams)"
0.169 "RMSE-free Ohms"
202.854 "Fs Hz"
3.473 "Re Ohms[dc]"
23.567 "Res Ohms"
6.487 "Qms "
0.956 "Qes "
0.833 "Qts "
0.065 "L1 mH"
0.058 "L2 mH"
0.827 "R2 Ohms"
0.130 "RMSE-load Ohms"
0.092 "Vas(Sd) liters"
1.551 "Mms grams"
396.893 "Cms �M/Newton"
2.680 "Bl Tesla-M"
80.900 "SPLref(Sd) dB "
0.043 "Rub-index "
';
my $regex = qr/(\d+.\d+) "([\w]+)/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