列表

详情


JS23. 身份证

描述

请补全JavaScript代码,要求以Boolean的形式返回字符串参数是否符合身份证标准。
注意:
1. 无需考虑地区信息、出生日期、顺序码与校验码的验证

示例1

输入:

_isCard('21062319980907888X')

输出:

true

原站题解

HTML/CSS/JavaScript 解法, 执行用时: 1688ms, 内存消耗: 77792KB, 提交时间: 2022-02-10

{"css":"","js":"","html":"<!DOCTYPE html>\n<html lang=\"en\">\n    <head>\n        <meta charset=\"UTF-8\">\n    </head>\n    <body>\n\n        <script>\nconst _isCard = number => {\n    var regx = /(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)/\n    return regx.test(number)\n}\n\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1752ms, 内存消耗: 77868KB, 提交时间: 2022-01-03

{"css":"","js":"","html":"<!DOCTYPE html>\n<html lang=\"en\">\n    <head>\n        <meta charset=\"UTF-8\">\n    </head>\n    <body>\n\n        <script>\n            const _isCard = number => {\n                // 补全代码\n                let 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]$/g\n                return reg.test(number)\n            }\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1753ms, 内存消耗: 77776KB, 提交时间: 2021-12-09

{"css":"","js":"","html":"<!DOCTYPE html>\n<html lang=\"en\">\n    <head>\n        <meta charset=\"UTF-8\">\n    </head>\n    <body>\n\n        <script>\n            const _isCard = number => {\n                // 补全代码\n                let reg = /(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}[X|x]$)/\n               return reg.test(number+'')\n            }\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1754ms, 内存消耗: 77900KB, 提交时间: 2022-01-25

{"css":"","js":"","html":"<!DOCTYPE html>\n<html lang=\"en\">\n    <head>\n        <meta charset=\"UTF-8\">\n    </head>\n    <body>\n\n        <script>\n            const _isCard = number => {\n                // 补全代码\n                let reg = /^(^[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])$)$/\n          return  reg.test(number)\n                }\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1755ms, 内存消耗: 77856KB, 提交时间: 2022-01-27

{"css":"","js":"","html":"<!DOCTYPE html>\n<html lang=\"en\">\n    <head>\n        <meta charset=\"UTF-8\">\n    </head>\n    <body>\n\n        <script>\n            const _isCard = number => {\n                // 补全代码\n               let  reg = /^[\\d]{17}[X\\d]{1}$/\n              return   reg.test(number)\n            }\n        </script>\n    </body>\n</html>","libs":[]}

上一题