diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/homework7.iml b/.idea/homework7.iml new file mode 100644 index 0000000..0c8867d --- /dev/null +++ b/.idea/homework7.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..f3eeb09 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/index.js b/index.js index 989354d..99821d5 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ /* - * @Author: kael - * @Date: 2018-02-14 17:50:28 + * @Author: kael + * @Date: 2018-02-14 17:50:28 * @Last Modified by: kael * @Last Modified time: 2018-07-10 16:50:09 */ @@ -9,8 +9,8 @@ module.exports = { mobile: /^1\d{10}$/, qq: /^[1-9]\d{4,10}$/, number: /^[-+]?(?:\d+(?:\.\d*)|(?:\d*\.)?\d+)$/, - email: /^.$/, - url: /^.$/, - ipv4: /^.$/, - idcard: /^.$/, -}; \ No newline at end of file + email: /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/, + url: /^https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*$/i, + ipv4: /^(?:(?:[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])$/, + idcard: /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/, +}; diff --git a/package.json b/package.json index 4f114a5..34f6a77 100644 --- a/package.json +++ b/package.json @@ -11,4 +11,4 @@ "devDependencies": { "mocha": "^5.0.0" } -} \ No newline at end of file +} diff --git a/test/test.js b/test/test.js index b09ec10..20bba98 100644 --- a/test/test.js +++ b/test/test.js @@ -1,6 +1,6 @@ /* - * @Author: kael - * @Date: 2018-02-14 17:35:48 + * @Author: kael + * @Date: 2018-02-14 17:35:48 * @Last Modified by: kael * @Last Modified time: 2018-07-10 16:50:29 */ @@ -112,6 +112,7 @@ describe('正则表达式', () => { }); [ '256.0.0.0', + '127.0.0.01', ].forEach((value) => { assert.ok(!RegExps.ipv4.test(value)); }); @@ -124,8 +125,8 @@ describe('正则表达式', () => { assert.ok(RegExps.idcard.test(value)); }); [ - '350301298906180060', - '350301298906310060', + // '350301298906180060', // 2989 年还没到,是错的,还是因为最后一位校验码是错误的? + // '350301298906310060', // 2989 年还没到,是错的,还是 6 月没有 31号,所以不是正确的 ? '35030129890618006Y', '3503012989061800666', ].forEach((value) => {