I am building an application that uses a child process to make mathematical calculations:
var child = exec('get_hrv -M -R rr.txt', function(error, stdout) {
if (error !== null) {
console.log('exec error: ' + error);
} else {
res.send(stdout);
}
});
The output (stdout) looks like this:
NN/RR = 0.992424
AVNN = 789.443
SDNN = 110.386
SDANN = 0
SDNNIDX = 110.386
rMSSD = 73.5775
pNN50 = 36.9231
TOT PWR = 12272.8
ULF PWR = 788.161
VLF PWR = 4603.59
LF PWR = 4221.97
HF PWR = 2659.05
LF/HF = 1.58777
Everything is working as it should, however, this output is a string and I need the values it contains assigned to separate integer variables, e.g. like this:
var extractedVars = {
NN/RR: 0.992424
AVNN: 789.443
SDNN: 110.386
SDANN: 0
SDNNIDX: 110.386
rMSSD: 73.5775
pNN50: 36.9231
TOT PWR: 12272.8
ULF PWR: 788.161
VLF PWR: 4603.59
LF PWR: 4221.97
HF PWR: 2659.05
LF/HF: 1.58777
}
How can this be done? Regex?