export function isExternal(path) { return /^(https?:|mailto:|tel:)/.test(path); } export function isPassword(str) { return str.length >= 5; } export function isNumber(value) { const reg = /^[0-9]*$/; return reg.test(value); } export function isName(value) { const reg = /^[\u4e00-\u9fa5a-zA-Z0-9]+$/; return reg.test(value); } export function isIP(ip) { const reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/; return reg.test(ip); } export function isUrl(url) { const reg = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/; return reg.test(url); } export function isLowerCase(str) { const reg = /^[a-z]+$/; return reg.test(str); } export function isUpperCase(str) { const reg = /^[A-Z]+$/; return reg.test(str); } export function isAlphabets(str) { const reg = /^[A-Za-z]+$/; return reg.test(str); } export function isString(str) { return typeof str === "string" || str instanceof String; } export function isArray(arg) { if (typeof Array.isArray === "undefined") { return Object.prototype.toString.call(arg) === "[object Array]"; } return Array.isArray(arg); } export function isPort(str) { const reg = /^([0-9]|[1-9]\d|[1-9]\d{2}|[1-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/; return reg.test(str); } export function isPhone(str) { const reg = /^1\d{10}$/; return reg.test(str); } export function isIdCard(str) { const reg = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/; return reg.test(str); } export function isEmail(str) { const reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; return reg.test(str); } export function isChina(str) { const reg = /^[\u4E00-\u9FA5]{2,4}$/; return reg.test(str); } export function isBlank(str) { return ( str == null || false || str === "" || str.trim() === "" || str.toLocaleLowerCase().trim() === "null" ); } export function isTel(str) { const reg = /^(400|800)([0-9\\-]{7,10})|(([0-9]{4}|[0-9]{3})(-| )?)?([0-9]{7,8})((-| |转)*([0-9]{1,4}))?$/; return reg.test(str); } export function isNum(str) { const reg = /^\d+(\.\d{1,2})?$/; return reg.test(str); }