mirror of
https://github.com/any86/any-rule.git
synced 2025-07-14 15:38:58 +08:00
Merge branch 'develop' into master
This commit is contained in:
commit
4fafde7efc
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,5 +1,12 @@
|
|||||||
out
|
out
|
||||||
node_modules
|
node_modules
|
||||||
|
coverage
|
||||||
|
.nyc_output
|
||||||
.vscode-test/
|
.vscode-test/
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
.DS_Store
|
||||||
*.vsix
|
*.vsix
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
|
.rpt2_cache
|
||||||
|
dist
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
# 更新日志
|
# 更新日志
|
||||||
🚀 [提交问题](https://github.com/any86/any-rule/issues/new)
|
🚀 [提交问题](https://github.com/any86/any-rule/issues/new)
|
||||||
|
|
||||||
|
### 0.3.12(2021-10-20)
|
||||||
|
- 修复网址中带有"()"不能通过.
|
||||||
|
- 新增"整数"/"浮点数"等正则.
|
||||||
|
|
||||||
|
### 0.3.11(2021-09-26)
|
||||||
|
- 修复新版vscode中"@zz"字符失效.
|
||||||
|
- 优化"身份证15/18"正则.
|
||||||
|
|
||||||
### 0.3.10(2021-05-28)
|
### 0.3.10(2021-05-28)
|
||||||
- 禁止"日期"可以通过"00"月和"00"日
|
- 禁止"日期"可以通过"00"月和"00"日
|
||||||
### 0.3.9(2021-04-20)
|
### 0.3.9(2021-04-20)
|
||||||
|
35
README.md
35
README.md
@ -1,4 +1,6 @@
|
|||||||
# 正则大全  [](https://marketplace.visualstudio.com/items?itemName=russell.any-rule) [](https://marketplace.visualstudio.com/items?itemName=russell.any-rule) [](https://marketplace.visualstudio.com/items?itemName=russell.any-rule)  [](https://circleci.com/gh/any86/any-rule)
|
|
||||||
|
# 正则大全  [](https://marketplace.visualstudio.com/items?itemName=russell.any-rule) [](https://marketplace.visualstudio.com/items?itemName=russell.any-rule) [](https://marketplace.visualstudio.com/items?itemName=russell.any-rule)  [](https://circleci.com/gh/any86/any-rule)
|
||||||
|
|
||||||
|
|
||||||
🦕支持**web** / **vscode** / **idea** / **Alfred Workflow**多平台
|
🦕支持**web** / **vscode** / **idea** / **Alfred Workflow**多平台
|
||||||
|
|
||||||
@ -78,7 +80,7 @@ vscode应用商店中搜索"**any-rule**".
|
|||||||
|
|
||||||
### 网址(url,支持端口和"?+参数"和"#+参数)
|
### 网址(url,支持端口和"?+参数"和"#+参数)
|
||||||
```javascript
|
```javascript
|
||||||
/^(((ht|f)tps?):\/\/)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?$/
|
/^(((ht|f)tps?):\/\/)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-\(\)]*[\w@?^=%&/~+#-\(\)])?$/
|
||||||
```
|
```
|
||||||
|
|
||||||
### 统一社会信用代码
|
### 统一社会信用代码
|
||||||
@ -148,7 +150,7 @@ vscode应用商店中搜索"**any-rule**".
|
|||||||
|
|
||||||
### html注释
|
### html注释
|
||||||
```javascript
|
```javascript
|
||||||
/^<!--[\s\S]*?-->$/
|
/<!--[\s\S]*?-->/g
|
||||||
```
|
```
|
||||||
|
|
||||||
### md5格式(32位)
|
### md5格式(32位)
|
||||||
@ -273,7 +275,7 @@ vscode应用商店中搜索"**any-rule**".
|
|||||||
|
|
||||||
### 身份证号, 支持1/2代(15位/18位数字)
|
### 身份证号, 支持1/2代(15位/18位数字)
|
||||||
```javascript
|
```javascript
|
||||||
/(^\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)$)/
|
/^\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)$/
|
||||||
```
|
```
|
||||||
|
|
||||||
### 护照(包含香港、澳门)
|
### 护照(包含香港、澳门)
|
||||||
@ -414,4 +416,29 @@ vscode应用商店中搜索"**any-rule**".
|
|||||||
### 大写字母,小写字母,数字,特殊符号 `@#$%^&*`~()-+=` 中任意3项密码
|
### 大写字母,小写字母,数字,特殊符号 `@#$%^&*`~()-+=` 中任意3项密码
|
||||||
```javascript
|
```javascript
|
||||||
/^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_!@#$%^&*`~()-+=]+$)(?![a-z0-9]+$)(?![a-z\W_!@#$%^&*`~()-+=]+$)(?![0-9\W_!@#$%^&*`~()-+=]+$)[a-zA-Z0-9\W_!@#$%^&*`~()-+=]/
|
/^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_!@#$%^&*`~()-+=]+$)(?![a-z0-9]+$)(?![a-z\W_!@#$%^&*`~()-+=]+$)(?![0-9\W_!@#$%^&*`~()-+=]+$)[a-zA-Z0-9\W_!@#$%^&*`~()-+=]/
|
||||||
|
|
||||||
|
### 正整数,不包含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_-]+)+$/
|
||||||
|
|
||||||
```
|
```
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "any-rule",
|
"name": "any-rule",
|
||||||
"version": "0.3.10",
|
"version": "0.3.12",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
29
package.json
29
package.json
@ -3,7 +3,7 @@
|
|||||||
"publisher": "russell",
|
"publisher": "russell",
|
||||||
"displayName": "any-rule",
|
"displayName": "any-rule",
|
||||||
"description": "你要的\"正则\"都在这!",
|
"description": "你要的\"正则\"都在这!",
|
||||||
"version": "0.3.10",
|
"version": "0.3.12",
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"pre-push": "npm run test:rules"
|
"pre-push": "npm run test:rules"
|
||||||
@ -48,6 +48,11 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "@zz",
|
"default": "@zz",
|
||||||
"description": "触发字符串"
|
"description": "触发字符串"
|
||||||
|
},
|
||||||
|
"any-rule.supportedLanguages": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "*,javascript,javascriptreact,typescript,typescriptreact,vue,vue-postcss,vue-sugarss,vue-html,json,jsonc,graphql,dart,sql,go,java,php,jade,python,swift,markdown",
|
||||||
|
"description": "支持的开发语言(用','分割)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -341,9 +346,29 @@
|
|||||||
"command": "extension.rule69",
|
"command": "extension.rule69",
|
||||||
"title": "$(rocket) zz: 台湾身份证 "
|
"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",
|
"command": "extension.rule.callByMenu",
|
||||||
"title": "🦕正则大全(70条)"
|
"title": "🦕正则大全(75条)"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -376,7 +376,7 @@ main {
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
box-shadow: 1px 2px 3px 1px $primary;
|
box-shadow: 1px 2px 3px $primary;
|
||||||
&.success {
|
&.success {
|
||||||
&:after {
|
&:after {
|
||||||
content: '复制成功';
|
content: '复制成功';
|
||||||
@ -391,20 +391,19 @@ main {
|
|||||||
}
|
}
|
||||||
&:active {
|
&:active {
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
color: #444;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
transition: all 0.3s;
|
transition: all 0.3s;
|
||||||
opacity: 0.6;
|
color: rgba(255, 255, 255, 0.6)
|
||||||
box-shadow: none;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
> .btn-better {
|
> .btn-better {
|
||||||
@extend .btn-copy;
|
@extend .btn-copy;
|
||||||
background-color: $danger;
|
background-color: $danger;
|
||||||
box-shadow: 1px 2px 3px 1px $danger;
|
box-shadow: 1px 2px 3px $danger;
|
||||||
}
|
}
|
||||||
|
|
||||||
> code {
|
> code {
|
||||||
|
@ -16,8 +16,8 @@ module.exports = [{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '网址(url,支持端口和"?+参数"和"#+参数)',
|
title: '网址(url,支持端口和"?+参数"和"#+参数)',
|
||||||
rule: /^(((ht|f)tps?):\/\/)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?$/,
|
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', '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: ['....']
|
counterExamples: ['....']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -89,8 +89,8 @@ module.exports = [{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'html注释',
|
title: 'html注释',
|
||||||
rule: /^<!--[\s\S]*?-->$/,
|
rule: /<!--[\s\S]*?-->/g,
|
||||||
examples: ['<!--<div class="_bubble"></div>-->']
|
examples: ['<!--<div class="_bubble"></div>--><div>chenguzhen87</div><div class="_bubble"></div>-->']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'md5格式(32位)',
|
title: 'md5格式(32位)',
|
||||||
@ -115,7 +115,7 @@ module.exports = [{
|
|||||||
{
|
{
|
||||||
title: '图片(image)链接地址(图片格式可按需增删)',
|
title: '图片(image)链接地址(图片格式可按需增删)',
|
||||||
rule: /^https?:\/\/(.+\/)+.+(\.(gif|png|jpg|jpeg|webp|svg|psd|bmp|tif))$/i,
|
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)',
|
title: '24小时制时间(HH:mm:ss)',
|
||||||
@ -192,13 +192,13 @@ module.exports = [{
|
|||||||
{
|
{
|
||||||
title: 'date(日期)',
|
title: 'date(日期)',
|
||||||
rule: /^\d{1,4}(-)(1[0-2]|0?[1-9])\1(0?[1-9]|[1-2]\d|30|31)$/,
|
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'],
|
examples: ['1990-12-12', '1-1-1', '0000-1-1'],
|
||||||
counterExamples: ['2020-00-01']
|
counterExamples: ['2020-00-01']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'email(邮箱)',
|
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,}))$/,
|
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']
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -219,8 +219,8 @@ module.exports = [{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '身份证号, 支持1/2代(15位/18位数字)',
|
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)$)/,
|
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']
|
examples: ['622223199912051311','12345619991205131x','123456991010193']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '护照(包含香港、澳门)',
|
title: '护照(包含香港、澳门)',
|
||||||
@ -359,8 +359,34 @@ module.exports = [{
|
|||||||
examples: ['U193683453']
|
examples: ['U193683453']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
title: '大写字母,小写字母,数字,特殊符号 `@#$%^&*`~()-+=` 中任意3项密码',
|
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_!@#$%^&*`~()-+=]/,
|
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@']
|
examples: ['a1@','A1@','Aa@']
|
||||||
|
},
|
||||||
|
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']
|
||||||
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -87,16 +87,16 @@ function insertRule(document: TextDocument, position: Position, ruleString: stri
|
|||||||
// 获取配置
|
// 获取配置
|
||||||
function getConfig() {
|
function getConfig() {
|
||||||
const configuration = workspace.getConfiguration();
|
const configuration = workspace.getConfiguration();
|
||||||
const { triggerString } = configuration['any-rule'];
|
const { triggerString, supportedLanguages } = configuration['any-rule'];
|
||||||
const { length } = triggerString;
|
const { length } = triggerString;
|
||||||
const triggerStringStart = triggerString.substr(0, length - 1);
|
const triggerStringStart = triggerString.substr(0, length - 1);
|
||||||
const triggerStringEnd = triggerString.substr(-1);
|
const triggerStringEnd = triggerString.substr(-1);
|
||||||
|
console.log(supportedLanguages);
|
||||||
return {
|
return {
|
||||||
triggerStringStart,
|
triggerStringStart,
|
||||||
triggerStringEnd,
|
triggerStringEnd,
|
||||||
triggerString,
|
triggerString,
|
||||||
// 预留
|
// 预留
|
||||||
supportedLanguages: '*'
|
supportedLanguages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user