牛客网 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);    //输出
});

上一篇:17 line render


下一篇:2022.1.9日报:修复input placeholder导致位置不准的问题