1
rabbbit 2018-11-23 16:47:25 +08:00
function t(str) {
const reg1 = /^([\u0000-\u007F]|[\u4E00-\u9FCC\u3400-\u4DB5\uFA0E\uFA0F\uFA11\uFA13\uFA14\uFA1F\uFA21\uFA23\uFA24\uFA27-\uFA29]|[\ud840-\ud868][\udc00-\udfff]|\ud869[\udc00-\uded6\udf00-\udfff]|[\ud86a-\ud86c][\udc00-\udfff]|\ud86d[\udc00-\udf34\udf40-\udfff]|\ud86e[\udc00-\udc1d]){0,10}$/; const reg2 = /[()<>]+/; if (reg1.test(str) && (!reg2.test(str))) { return true; } else { return false; } } console.log(t('1234567890') === true) console.log(t('12345678901') === false) console.log(t('azAZ') === true) console.log(t('niconiconico') === false) console.log(t('全') === true) console.log(t('()') === false) console.log(t('<>') === false) console.log(t(`!"#$%&*+,.`) === true) console.log(t(`𠀐𠀐𠀐𠀐𠀐𠀐𠀐𠀐𠀐𠀐`) === true) console.log(t(`𠀐𠀐𠀐𠀐𠀐𠀐𠀐𠀐𠀐𠀐𠀐`)=== false) console.log(t('。') === false) console.log(t(',') === false) console.log(t('”') === false) console.log(t(':') === false) console.log(t('¥') === false) console.log(t('『') === false) |