题解 | #在字符串中找出连续最长的数字串#
在字符串中找出连续最长的数字串
https://www.nowcoder.com/practice/2c81f88ecd5a4cc395b5308a99afbbec
const rl = require("readline").createInterface({ input: process.stdin }); var iter = rl[Symbol.asyncIterator](); const readline = async () => (await iter.next()).value; void async function () { while(line = await readline()){ let max = 1; let maxStrArr = []; for(let i =0;i<line.length;i++){ for(let j=i+1;j<=line.length;j++){ let tempStr = line.slice(i,j); if(tempStr.length > max && !/[^0-9]/.test(tempStr)){ max = tempStr.length; maxStrArr = [tempStr]; } else if(tempStr.length === max && !/[^0-9]/.test(tempStr)){ maxStrArr.push(tempStr); } } } console.log(maxStrArr.join('')+','+max); } }()