Merge pull request #201 from songjianet/develop-number

feat: Increase number-related regular verification
This commit is contained in:
any86 2021-10-20 10:05:39 +08:00 committed by GitHub
commit 8fd08708dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 80 additions and 3 deletions

9
.gitignore vendored
View File

@ -1,5 +1,12 @@
out
node_modules
coverage
.nyc_output
.vscode-test/
.idea
.vscode
.DS_Store
*.vsix
yarn-error.log
yarn-error.log
.rpt2_cache
dist

View File

@ -410,3 +410,28 @@ vscode应用商店中搜索"**any-rule**".
```javascript
/^[a-zA-Z][0-9]{9}$/
```
### 正整数不包含0
```javascript
/^\+?[1-9]\d*$/
```
### 负整数不包含0
```javascript
/^-[1-9]\d*$/
```
### 整数
```javascript
/^-?[0-9]\d*$/
```
### 浮点数
```javascript
/^(-?\d+)(\.\d+)?$/
```
### email(支持中文邮箱)
```javascript
/^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
```

View File

@ -341,6 +341,26 @@
"command": "extension.rule69",
"title": "$(rocket) zz: 台湾身份证 "
},
{
"command": "extension.rule70",
"title": "$(rocket) zz: 正整数不包含0 "
},
{
"command": "extension.rule71",
"title": "$(rocket) zz: 负整数不包含0 "
},
{
"command": "extension.rule72",
"title": "$(rocket) zz: 整数 "
},
{
"command": "extension.rule73",
"title": "$(rocket) zz: 浮点数 "
},
{
"command": "extension.rule74",
"title": "$(rocket) zz: email(支持中文邮箱) "
},
{
"command": "extension.rule.callByMenu",
"title": "🦕正则大全(70条)"

View File

@ -17,7 +17,7 @@ module.exports = [{
{
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'],
examples: ['www.qq.com', 'https://baidu.com', 'http://baidu.com', '360.com:8080/vue/#/a=1&b=2'],
counterExamples: ['....']
},
{
@ -115,7 +115,7 @@ module.exports = [{
{
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',
@ -358,4 +358,29 @@ module.exports = [{
rule: /^[a-zA-Z][0-9]{9}$/,
examples: ['U193683453']
},
{
title: '正整数不包含0',
rule: /^\+?[1-9]\d*$/,
examples: [1231]
},
{
title: '负整数不包含0',
rule: /^-[1-9]\d*$/,
examples: [-1231]
},
{
title: '整数',
rule: /^-?[0-9]\d*$/,
examples: [-1231, 123]
},
{
title: '浮点数',
rule: /^(-?\d+)(\.\d+)?$/,
examples: [1.5]
},
{
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']
}
];