I know how to format a string using %f, %d etc. using util.format(). Can someone tell me which is the complementary function that enables SCANNING from a string (not from console input).
For example:
Running...
const util = require('util');
var weatherStr = util.format(`The temperature at %d o' clock was %f deg. C and the humidity was %f.`, 5, 23.9, 0.5);
console.log(weatherStr);
...generates...
The temperature at 5 o' clock was 23.9 deg. C and the humidity was 0.5.
I was expecting a util function which would work such that running the following code...
const util = require('util');
var weatherStr = 'The temperature at 5 o' clock was 23.9 deg. C and the humidity was 0.5.';
console.log(util.????(tempStr, `humidity was %f.`));
...generates...
0.5
Which is the util function that does this? I don't think "parseFloat" will work because it will extract 23.9.
I'm new to JS and Node but I expected a "scan" function. I know there is a scanf npm library but it seems to work with console input rather than existing strings. I have been doing searches for "%f" among JS and Node functions and surprisingly util.format seems to be the only one with a mention of it.