'How do I find a certain word in the text file and send the value that would be the word?
const fs = require('fs');
fs.readFile('./test.txt', function(error, data) {
if (!error) {
data = data.toString();
const firstLine = data.split('\n')[0];
console.log(`${firstLine}`)
}
});
Imagine that in file test.txt you have the following words:
Hello\nHi\nTest
I want to find word Hi and return that value in ${firstLine}.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
