题解 | #合法IP#
合法IP
https://www.nowcoder.com/practice/995b8a548827494699dc38c3e2a54ee9
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.on("line", function (line) {
const arr = line.split(".");
console.log(
arr.length === 4 &&
arr.every(
(num) =>
/^[0-9]{1,3}$/.test(num) && (num.length == 1 ||
num.length > 1 &&
!num.startsWith("0") &&
Number(num) >= 0 &&
Number(num) <= 255)
)
? "YES"
: "NO"
);
});

