mirror of
https://github.com/fantastic-admin/basic.git
synced 2026-10-07 17:08:27 +08:00
更新 any-rule 正则
This commit is contained in:
@@ -27,9 +27,13 @@ const rules = ref([
|
||||
counterExamples: ['192.168.1.1', 'https://www.jd.com'],
|
||||
},
|
||||
{
|
||||
title: '网址(url,支持端口和"?+参数"和"#+参数)',
|
||||
rule: /^(((ht|f)tps?):\/\/)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?$/,
|
||||
examples: ['www.qq.com', 'https://baidu.com', '360.com:8080/vue/#/a=1&b=2'],
|
||||
// 参考:
|
||||
// https://baike.baidu.com/item/%E9%A1%B6%E7%BA%A7%E5%9F%9F%E5%90%8D#4_1
|
||||
// https://baike.baidu.com/item/%E9%A1%B6%E7%BA%A7%E5%9F%9F%E5%90%8D#7
|
||||
// 也参考谷歌浏览器的地址栏, 如果输入非字母不会被识别为域名
|
||||
title: '网址(URL)',
|
||||
rule: /^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-]([^!@#$%^&*?.\s]{0,63}[^!@#$%^&*?.\s])?\.)+[a-z]{2,6}\/?/,
|
||||
examples: ['www.qq.com', 'https://vuejs.org/v2/api/#v-model', 'www.qq.99', '//www.qq.com', 'www.腾讯.cs', 'ftp://baidu.qq', 'http://baidu.com', 'https://www.amap.com/search?id=BV10060895&city=420111&geoobj=113.207951%7C29.992557%7C115.785782%7C31.204369&query_type=IDQ&query=%E5%85%89%E8%B0%B7%E5%B9%BF%E5%9C%BA(%E5%9C%B0%E9%93%81%E7%AB%99)&zoom=10.15', '360.com:8080/vue/#/a=1&b=2'],
|
||||
counterExamples: ['....'],
|
||||
},
|
||||
{
|
||||
@@ -60,9 +64,9 @@ const rules = ref([
|
||||
examples: ['magnet:?xt=urn:btih:40A89A6F4FB1498A98087109D012A9A851FBE0FC'],
|
||||
},
|
||||
{
|
||||
title: '子网掩码',
|
||||
rule: /^(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(?:\.(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/,
|
||||
examples: ['255.255.255.0', '255.224.0.0'],
|
||||
title: '子网掩码(不包含 0.0.0.0)',
|
||||
rule: /^(254|252|248|240|224|192|128)\.0\.0\.0|255\.(254|252|248|240|224|192|128|0)\.0\.0|255\.255\.(254|252|248|240|224|192|128|0)\.0|255\.255\.255\.(255|254|252|248|240|224|192|128|0)$/,
|
||||
examples: ['255.255.255.0', '255.255.255.255', '255.240.0.0'],
|
||||
},
|
||||
{
|
||||
title: 'linux"隐藏文件"路径',
|
||||
@@ -72,7 +76,7 @@ const rules = ref([
|
||||
{
|
||||
title: 'linux文件夹路径',
|
||||
rule: /^\/(?:[^/]+\/)*$/,
|
||||
examples: ['/usr/ad/dd/', '/', '/root/'],
|
||||
examples: ['/usr/ad/dd/', '/', '/root/', '/ a a / a / a a /'],
|
||||
},
|
||||
{
|
||||
title: 'linux文件路径',
|
||||
@@ -101,12 +105,12 @@ const rules = ref([
|
||||
},
|
||||
{
|
||||
title: 'html注释',
|
||||
rule: /^<!--[\s\S]*?-->$/,
|
||||
examples: ['<!--<div class="_bubble"></div>-->'],
|
||||
rule: /<!--[\s\S]*?-->/g,
|
||||
examples: ['<!--<div class="_bubble"></div>--><div>chenguzhen87</div><div class="_bubble"></div>-->'],
|
||||
},
|
||||
{
|
||||
title: 'md5格式(32位)',
|
||||
rule: /^([a-f\d]{32}|[A-F\d]{32})$/,
|
||||
rule: /^[a-fA-F0-9]{32}$/,
|
||||
examples: ['21fe181c5bfc16306a6828c1f7b762e8'],
|
||||
},
|
||||
{
|
||||
@@ -127,7 +131,7 @@ const rules = ref([
|
||||
{
|
||||
title: '图片(image)链接地址(图片格式可按需增删)',
|
||||
rule: /^https?:\/\/(.+\/)+.+(\.(gif|png|jpg|jpeg|webp|svg|psd|bmp|tif))$/i,
|
||||
examples: ['https://www.abc.com/logo.png'],
|
||||
examples: ['https://www.abc.com/logo.png', 'http://www.abc.com/logo.png'],
|
||||
},
|
||||
{
|
||||
title: '24小时制时间(HH:mm:ss)',
|
||||
@@ -147,14 +151,9 @@ const rules = ref([
|
||||
},
|
||||
{
|
||||
title: '数字/货币金额(支持负数、千分位分隔符)',
|
||||
rule: /^-?\d+(,\d{3})*(\.\d{1,2})?$/,
|
||||
rule: /^-?\d{1,3}(,\d{3})*(\.\d{1,2})?$/,
|
||||
examples: [100, -0.99, 3, 234.32, -1, 900, 235.09, '12,345,678.90'],
|
||||
},
|
||||
{
|
||||
title: '数字/货币金额 (只支持正数、不支持校验千分位分隔符)',
|
||||
rule: /(?:^[1-9]([0-9]+)?(?:\.[0-9]{1,2})?$)|(?:^(?:0)$)|(?:^[0-9]\.[0-9](?:[0-9])?$)/,
|
||||
examples: [0.99, 8.99, 666],
|
||||
},
|
||||
{
|
||||
title: '银行卡号(10到30位, 覆盖对公/私账户, 参考[微信支付](https://pay.weixin.qq.com/wiki/doc/api/xiaowei.php?chapter=22_1))',
|
||||
rule: /^[1-9]\d{9,29}$/,
|
||||
@@ -172,8 +171,8 @@ const rules = ref([
|
||||
},
|
||||
{
|
||||
title: '车牌号(新能源)',
|
||||
rule: /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z](?:((\d{5}[A-HJK])|([A-HJK][A-HJ-NP-Z0-9][0-9]{4}))|[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳])$/,
|
||||
examples: ['京AD92035', '甘G23459F', '京AA92035'],
|
||||
rule: /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z](([DF]((?![IO])[a-zA-Z0-9](?![IO]))[0-9]{4})|([0-9]{5}[DF]))$/,
|
||||
examples: ['京AD92035', '甘G23459F', '京A19203D'],
|
||||
},
|
||||
{
|
||||
title: '车牌号(非新能源)',
|
||||
@@ -187,9 +186,9 @@ const rules = ref([
|
||||
counterExamples: ['宁AD1234555555', '浙苏H6F681'],
|
||||
},
|
||||
{
|
||||
title: '手机号(mobile phone)中国(严谨), 根据工信部2019年最新公布的手机号段',
|
||||
rule: /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/,
|
||||
examples: ['008618311006933', '+8617888829981', '19119255642'],
|
||||
title: '手机号(mobile phone)中国(严谨), 根据工信部最新公布的手机号段',
|
||||
rule: /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[01256789]))\d{8}$/,
|
||||
examples: ['008618311006933', '+8617888829981', '19119255642', '19519255642'],
|
||||
},
|
||||
{
|
||||
title: '手机号(mobile phone)中国(宽松), 只要是13,14,15,16,17,18,19开头即可',
|
||||
@@ -202,15 +201,36 @@ const rules = ref([
|
||||
examples: ['008618311006933', '+8617888829981', '19119255642'],
|
||||
},
|
||||
{
|
||||
title: 'date(日期)',
|
||||
title: '日期(宽松)',
|
||||
rule: /^\d{1,4}(-)(1[0-2]|0?[1-9])\1(0?[1-9]|[1-2]\d|30|31)$/,
|
||||
examples: ['1990-12-12', '1-1-1', '0000-1-1'],
|
||||
counterExamples: ['2020-00-01'],
|
||||
},
|
||||
|
||||
{
|
||||
title: '日期(严谨, 支持闰年判断)',
|
||||
rule: /^(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29)$/,
|
||||
examples: ['1990-12-12', '2000-02-29'],
|
||||
counterExamples: ['2021-02-29'],
|
||||
},
|
||||
|
||||
{
|
||||
title: '中国省',
|
||||
rule: /^浙江|上海|北京|天津|重庆|黑龙江|吉林|辽宁|内蒙古|河北|新疆|甘肃|青海|陕西|宁夏|河南|山东|山西|安徽|湖北|湖南|江苏|四川|贵州|云南|广西|西藏|江西|广东|福建|台湾|海南|香港|澳门$/,
|
||||
examples: ['浙江', '台湾'],
|
||||
counterExamples: ['哈尔滨'],
|
||||
},
|
||||
|
||||
{
|
||||
title: '可以被moment转化成功的时间 YYYYMMDD HH:mm:ss',
|
||||
rule: /^\d{4}([/:-\S])(1[0-2]|0?[1-9])\1(0?[1-9]|[1-2]\d|30|31) (?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d$/,
|
||||
examples: ['2020/01/01 23:59:59', '2020-01-01 00:00:00', '20200101 11:11:11'],
|
||||
counterExamples: ['2020/00/01 23:59:59', '2020-01/01 23:59:59', '2020-01-01 23:59:61', '2020-01-0100:00:00'],
|
||||
},
|
||||
{
|
||||
title: 'email(邮箱)',
|
||||
rule: /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
|
||||
examples: ['90203918@qq.com', 'nbilly@126.com'],
|
||||
examples: ['90203918@qq.com', 'nbilly@126.com', '汉字@qq.com'],
|
||||
},
|
||||
|
||||
{
|
||||
@@ -231,8 +251,8 @@ const rules = ref([
|
||||
},
|
||||
{
|
||||
title: '身份证号, 支持1/2代(15位/18位数字)',
|
||||
rule: /(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0[1-9]|10|11|12)([0-2]\d|30|31)\d{3}(\d|X|x)$)/,
|
||||
examples: ['622223199912051311'],
|
||||
rule: /^\d{6}((((((19|20)\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(((19|20)\d{2})(0[13578]|1[02])31)|((19|20)\d{2})02(0[1-9]|1\d|2[0-8])|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))0229))\d{3})|((((\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|((\d{2})(0[13578]|1[02])31)|((\d{2})02(0[1-9]|1\d|2[0-8]))|(([13579][26]|[2468][048]|0[048])0229))\d{2}))(\d|X|x)$/,
|
||||
examples: ['622223199912051311', '12345619991205131x', '123456991010193'],
|
||||
},
|
||||
{
|
||||
title: '护照(包含香港、澳门)',
|
||||
@@ -251,13 +271,13 @@ const rules = ref([
|
||||
examples: ['正则', '前端'],
|
||||
},
|
||||
{
|
||||
title: '小数',
|
||||
rule: /^\d+\.\d+$/,
|
||||
examples: ['0.0', '0.09'],
|
||||
title: '小数(支持科学计数)',
|
||||
rule: /^[+-]?(\d+([.]\d*)?([eE][+-]?\d+)?|[.]\d+([eE][+-]?\d+)?)$/,
|
||||
examples: ['0.0', '0.09', '4E+4'],
|
||||
},
|
||||
{
|
||||
title: '数字',
|
||||
rule: /^\d{1,}$/,
|
||||
title: '只包含数字',
|
||||
rule: /^\d+$/,
|
||||
examples: [12345678],
|
||||
},
|
||||
{
|
||||
@@ -265,6 +285,13 @@ const rules = ref([
|
||||
rule: /<(\w+)[^>]*>(.*?<\/\1>)?/,
|
||||
examples: ['<div id="app"> 2333 </div>', '<input type="text">', '<br>'],
|
||||
},
|
||||
|
||||
{
|
||||
title: '匹配中文汉字和中文标点',
|
||||
rule: /[\u4E00-\u9FA5|\u3002|\uFF1F|\uFF01|\uFF0C|\u3001|\uFF1B|\uFF1A|\u201C|\u201D|\u2018|\u2019|\uFF08|\uFF09|\u300A|\u300B|\u3008|\u3009|\u3010|\u3011|\u300E|\u300F|\u300C|\u300D|\uFE43|\uFE44|\u3014|\u3015|\u2026|\u2014|\uFF5E|\uFE4F|\uFFE5]/,
|
||||
examples: ['匹配中文汉字以及中文标点符号 。 ? ! , 、 ; : “ ” ‘ \' ( ) 《 》 〈 〉 【 】 『 』 「 」 ﹃ ﹄ 〔 〕 … — ~ ﹏ ¥'],
|
||||
},
|
||||
|
||||
{
|
||||
title: 'qq号格式正确',
|
||||
rule: /^[1-9][0-9]{4,10}$/,
|
||||
@@ -297,7 +324,7 @@ const rules = ref([
|
||||
},
|
||||
{
|
||||
title: '用户名校验,4到16位(字母,数字,下划线,减号)',
|
||||
rule: /^[a-zA-Z0-9_-]{4,16}$/,
|
||||
rule: /^[\w-]{4,16}$/,
|
||||
examples: ['xiaohua_qq'],
|
||||
},
|
||||
{
|
||||
@@ -307,8 +334,8 @@ const rules = ref([
|
||||
},
|
||||
{
|
||||
title: '16进制颜色',
|
||||
rule: /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,
|
||||
examples: ['#f00', '#F90', '#000', '#fe9de8'],
|
||||
rule: /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3}|[a-fA-F0-9]{8}|[a-fA-F0-9]{4})$/,
|
||||
examples: ['#f00', '#F90', '#000', '#fe9de8', '#f8f8f8ff', '#f003'],
|
||||
},
|
||||
{
|
||||
title: '微信号(wx),6至20位,以字母开头,字母,数字,减号,下划线',
|
||||
@@ -337,7 +364,7 @@ const rules = ref([
|
||||
},
|
||||
{
|
||||
title: 'mac地址',
|
||||
rule: /^((([a-f0-9]{2}:){5})|(([a-f0-9]{2}-){5}))[a-f0-9]{2}$/i,
|
||||
rule: /^(([a-f0-9][0,2,4,6,8,a,c,e]:([a-f0-9]{2}:){4})|([a-f0-9][0,2,4,6,8,a,c,e]-([a-f0-9]{2}-){4}))[a-f0-9]{2}$/i,
|
||||
examples: ['38:f9:d3:4b:f5:51', '00-0C-29-CA-E4-66'],
|
||||
},
|
||||
{
|
||||
@@ -356,8 +383,10 @@ const rules = ref([
|
||||
examples: ['K034169(1)'],
|
||||
},
|
||||
{
|
||||
// 参考:
|
||||
// https://baike.baidu.com/item/%E6%BE%B3%E9%97%A8%E5%B1%85%E6%B0%91%E8%BA%AB%E4%BB%BD%E8%AF%81/12509098?fr=aladdin#5
|
||||
title: '澳门身份证 ',
|
||||
rule: /^[1|5|7]\d{6}[(\d)]{3}$/,
|
||||
rule: /^[1|5|7]\d{6}\(\d\)$/,
|
||||
examples: ['5686611(1)'],
|
||||
},
|
||||
{
|
||||
@@ -365,6 +394,72 @@ const rules = ref([
|
||||
rule: /^[a-zA-Z][0-9]{9}$/,
|
||||
examples: ['U193683453'],
|
||||
},
|
||||
{
|
||||
title: '大写字母,小写字母,数字,特殊符号 `@#$%^&*`~()-+=` 中任意3项密码',
|
||||
rule: /^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_!@#$%^&*`~()-+=]+$)(?![a-z0-9]+$)(?![a-z\W_!@#$%^&*`~()-+=]+$)(?![0-9\W_!@#$%^&*`~()-+=]+$)[a-zA-Z0-9\W_!@#$%^&*`~()-+=]/,
|
||||
examples: ['a1@', 'A1@', 'Aa@'],
|
||||
},
|
||||
{
|
||||
title: 'ASCII码表中的全部的特殊字符',
|
||||
rule: /[\x21-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E]+/,
|
||||
examples: ['[', '.', '^', '&3%'],
|
||||
},
|
||||
{
|
||||
title: '正整数,不包含0',
|
||||
rule: /^\+?[1-9]\d*$/,
|
||||
examples: [1231],
|
||||
},
|
||||
{
|
||||
title: '负整数,不包含0',
|
||||
rule: /^-[1-9]\d*$/,
|
||||
examples: [-1231],
|
||||
},
|
||||
{
|
||||
title: '整数',
|
||||
rule: /^(?:0|(?:-?[1-9]\d*))$/,
|
||||
examples: [-1231, 123, 0],
|
||||
counterExamples: ['01'],
|
||||
},
|
||||
{
|
||||
title: '浮点数',
|
||||
rule: /^(-?[1-9]\d*\.\d+|-?0\.\d*[1-9]\d*|0\.0+)$/,
|
||||
examples: ['1.23', '-1.01', '0.00'],
|
||||
// allow "1.23", allow "-0.1", allow "0.00", ban "-0.00", ban "2.", allow "2.0"
|
||||
},
|
||||
{
|
||||
title: '浮点数(严格)',
|
||||
rule: /^(-?[1-9]\d*\.\d+|-?0\.\d*[1-9])$/,
|
||||
examples: ['1.23', '-1.01'],
|
||||
// allow "1.23", allow "-0.1", ban "2.", ban "2.0"
|
||||
},
|
||||
{
|
||||
title: 'email(支持中文邮箱)',
|
||||
rule: /^[A-Za-z0-9\u4E00-\u9FA5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
|
||||
examples: ['90203918@qq.com', 'nbilly@126.com', '啦啦啦@126.com'],
|
||||
},
|
||||
|
||||
{
|
||||
title: '域名(非网址, 不包含协议)',
|
||||
rule: /^([0-9a-zA-Z-]{1,}\.)+([a-zA-Z]{2,})$/,
|
||||
examples: ['www.baidu.com',
|
||||
'baidu.com',
|
||||
'baidu.com.cn',
|
||||
'api.baidu.com',
|
||||
'nodejs.org',
|
||||
'nodejs.cn'],
|
||||
counterExamples: ['http://baidu.com', 'https://baidu.com', 'www.百度.com'],
|
||||
},
|
||||
|
||||
{
|
||||
title: '军官/士兵证',
|
||||
rule: /^[\u4E00-\u9FA5](字第)([0-9a-zA-Z]{4,8})(号?)$/,
|
||||
examples: ['军字第2001988号', '士字第P011816X号'],
|
||||
},
|
||||
{
|
||||
title: '户口薄',
|
||||
rule: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
|
||||
examples: ['441421999707223115'],
|
||||
},
|
||||
])
|
||||
|
||||
const dialog = ref({
|
||||
|
||||
Reference in New Issue
Block a user