const regex = /(\d+.\d+) "([\w]+)/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(\\d+.\\d+) "([\\w]+)', 'g')
const 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 "
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions