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+)?$/;