From 8a12c9d8029f1f2d5912b34c7c51bc7ee13270db Mon Sep 17 00:00:00 2001 From: LiuJiaNan <15703339975@163.com> Date: Thu, 2 Apr 2026 09:46:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(regular):=20=E6=B7=BB=E5=8A=A0=E5=BA=A7?= =?UTF-8?q?=E6=9C=BA=E5=8F=B7=E7=A0=81=E6=AD=A3=E5=88=99=E8=A1=A8=E8=BE=BE?= =?UTF-8?q?=E5=BC=8F=E5=B9=B6=E4=BC=98=E5=8C=96=E8=BD=A6=E7=89=8C=E5=8F=B7?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 TEL_PHONE 正则表达式用于匹配座机号码 - 优化 LICENSE_PLATE_NUMBER 正则表达式规则,支持更准确的车牌号匹配 - 更新车牌号正则表达式支持5位或6位数字字母组合 - 为新增的座机号码匹配功能添加类型定义文件导出 --- src/regular/index.d.ts | 5 +++++ src/regular/index.js | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/regular/index.d.ts b/src/regular/index.d.ts index cc447be..7e1b6f7 100644 --- a/src/regular/index.d.ts +++ b/src/regular/index.d.ts @@ -52,3 +52,8 @@ export const HTML_TAG: RegExp; * 匹配中国大陆的邮政编码。 */ export const POSTAL_CODE: RegExp; + +/** + * 匹配座机号码。 + */ +export const TEL_PHONE: RegExp; diff --git a/src/regular/index.js b/src/regular/index.js index b9f0a4f..ef76a6c 100644 --- a/src/regular/index.js +++ b/src/regular/index.js @@ -42,7 +42,7 @@ export const ONE_DECIMAL_PLACES = /^\d+(\.\d?)?$/; * 匹配中国大陆的车牌号码。 */ export const LICENSE_PLATE_NUMBER - = /^([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z][A-Z][A-Z0-9]{4}[A-Z0-9挂学警港澳])$/; + = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$/; /** * 匹配强密码,要求至少8个字符,包含大小写字母、数字和特殊字符。 @@ -59,3 +59,8 @@ export const HTML_TAG = /<[^>]*>/g; * 匹配中国大陆的邮政编码。 */ export const POSTAL_CODE = /^(0[1-7]|1[0-356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[0-5]|8[013-6])\d{4}$/g; + +/** + * 匹配座机号码。 + */ +export const TEL_PHONE = /^(?:(?:\d{3}-)?\d{8}|^(?:\d{4}-)?\d{7,8})(?:-\d+)?$/;