mirror of
https://github.com/tiennm99/is-a-good-dev.git
synced 2026-06-02 20:11:42 +00:00
15 lines
502 B
JavaScript
15 lines
502 B
JavaScript
module.exports.checkIfValidIP = function(str) {
|
|
// Regular expression to check if string is a IP address
|
|
const regexExp = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/gi
|
|
|
|
return regexExp.test(str);
|
|
};
|
|
|
|
module.exports.checkIfValidFQDN = function(str) {
|
|
// Regular expression to check if string is a FQDN
|
|
const regexExp = /(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9]\.)+[a-zA-Z]{2,63}$)/gi
|
|
|
|
return regexExp.test(str);
|
|
};
|
|
|