牛客网 JavaScript Node ACM 模式
作者:互联网
--------------------------------------个人笔记--------------------------------------
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
const arr = [];
rl.on('line', function (line) { // 一行一行地输入
arr.push(line);
if (arr.length === 2) {
rl.close();
}
});
rl.on('close', function() {
const matches = arr[0].match(new RegExp(arr[1], "ig"));
const len = matches === null ? 0 : matches.length;
console.log(len); //输出
});
标签:Node,arr,const,matches,JavaScript,牛客,rl,line,readline 来源: https://www.cnblogs.com/ran2022/p/15824804.html