牛客網 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);    //輸出
});


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM