我在js中逐行读取文件,并在引号内查找任何字符串,如下所示:
// regex to find all strings within double-quotes
var re = new RegExp("\"([^\"]*)\"");
// parse each line in inFile
var lineReader = require('readline').createInterface({
input: require('fs').createReadStream(inFile)
});
lineReader.on('line', function(line) {
var res = line.match(re)
// do something else here
});
如果引号内的每一行只有一个字符串,则效果很好。如何调整它以在同一行上迭代多个匹配?
由于