The response has been limited to 50k tokens of the smallest files in the repo. You can remove this limitation by removing the max tokens filter.
├── .circleci
    └── config.yml
├── .gitattributes
├── .github
    └── workflows
    │   └── nodejs.yml
├── .gitignore
├── .vscode
    ├── extensions.json
    ├── launch.json
    ├── settings.json
    └── tasks.json
├── .vscodeignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── __test__
    └── rule.js
├── images
    └── vscode-logo.png
├── package.json
├── packages
    └── www
    │   ├── .gitignore
    │   ├── LICENSE
    │   ├── babel.config.js
    │   ├── package.json
    │   ├── prettier.config.js
    │   ├── public
    │       ├── favicon.ico
    │       ├── icon.png
    │       ├── index.html
    │       ├── manifest.json
    │       └── sw.js
    │   ├── scripts
    │       └── demo.js
    │   ├── src
    │       ├── App.vue
    │       ├── RULES.js
    │       └── main.js
    │   └── vue.config.js
├── scripts
    ├── genCommond.js
    └── md.js
├── src
    ├── extension.ts
    ├── insertLog.ts
    ├── interface.d.ts
    ├── shared.ts
    ├── showResultMessage.ts
    ├── test
    │   ├── runTest.ts
    │   └── suite
    │   │   ├── extension.test.ts
    │   │   └── index.ts
    ├── useCommand.ts
    ├── useMenuCommand.ts
    └── useQuickPick.ts
├── tsconfig.json
├── tslint.json
├── webpack.config.js
└── yarn.lock


/.circleci/config.yml:
--------------------------------------------------------------------------------
 1 | # Javascript Node CircleCI 2.0 configuration file
 2 | #
 3 | # Check https://circleci.com/docs/2.0/language-javascript/ for more details
 4 | #
 5 | version: 2
 6 | jobs:
 7 |     build:
 8 |         filters:
 9 |             branches:
10 |                 ignore:
11 |                     - gh-pages
12 |         docker:
13 |         # specify the version you desire here
14 |         - image: circleci/node:12.14.1
15 |         
16 |         # Specify service dependencies here if necessary
17 |         # CircleCI maintains a library of pre-built images
18 |         # documented at https://circleci.com/docs/2.0/circleci-images/
19 |         # - image: circleci/mongo:3.4.4
20 | 
21 |         working_directory: ~/repo
22 | 
23 |         parallelism: 1
24 | 
25 |         steps:
26 |         - checkout
27 | 
28 |         # - restore_cache: 
29 |         #     key: dependency-cache-{{ checksum "package.json" }}
30 | 
31 |         # - run: yarn install
32 |         # - run: yarn add codecov
33 |         - run: yarn add chalk@2.4.2
34 | 
35 |         
36 | 
37 |         # - save_cache:
38 |         #     key: dependency-cache-{{ checksum "package.json" }}
39 |         #     paths:
40 |         #         - ./node_modules
41 |         # run tests!  
42 |         - run: yarn test:rules
43 |         # - run: ./node_modules/.bin/codecov
44 | 


--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | packages/*/** linguist-vendored


--------------------------------------------------------------------------------
/.github/workflows/nodejs.yml:
--------------------------------------------------------------------------------
 1 | name: Node CI
 2 | 
 3 | on: [push]
 4 | 
 5 | jobs:
 6 |   test:
 7 | 
 8 |     runs-on: ubuntu-latest
 9 | 
10 |     steps:
11 |     - uses: actions/checkout@master
12 |     - name: Use Node.js 10.x
13 |       uses: actions/setup-node@v1
14 |       with:
15 |         node-version: 10.x
16 |     - name: test
17 |       run: |
18 |         npm i
19 |         npm run test:rules
20 | 


--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
 1 | out
 2 | node_modules
 3 | coverage
 4 | .nyc_output
 5 | .vscode-test/
 6 | .idea
 7 | .vscode
 8 | .DS_Store
 9 | *.vsix
10 | yarn-error.log
11 | .rpt2_cache
12 | dist
13 | 


--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | 	// See http://go.microsoft.com/fwlink/?LinkId=827846
3 | 	// for the documentation about the extensions.json format
4 | 	"recommendations": [
5 | 		"ms-vscode.vscode-typescript-tslint-plugin"
6 | 	]
7 | }


--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
 1 | // A launch configuration that compiles the extension and then opens it inside a new window
 2 | // Use IntelliSense to learn about possible attributes.
 3 | // Hover to view descriptions of existing attributes.
 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
 5 | {
 6 | 	"version": "0.2.0",
 7 | 	"configurations": [
 8 | 		{
 9 | 			"name": "Run Extension",
10 | 			"type": "extensionHost",
11 | 			"request": "launch",
12 | 			"runtimeExecutable": "${execPath}",
13 | 			"args": [
14 | 				"--extensionDevelopmentPath=${workspaceFolder}"
15 | 			],
16 | 			"outFiles": [
17 | 				"${workspaceFolder}/out/**/*.js"
18 | 			],
19 | 			"preLaunchTask": "npm: watch"
20 | 		},
21 | 		{
22 | 			"name": "Extension Tests",
23 | 			"type": "extensionHost",
24 | 			"request": "launch",
25 | 			"runtimeExecutable": "${execPath}",
26 | 			"args": [
27 | 				"--extensionDevelopmentPath=${workspaceFolder}",
28 | 				"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
29 | 			],
30 | 			"outFiles": [
31 | 				"${workspaceFolder}/out/test/**/*.js"
32 | 			],
33 | 			"preLaunchTask": "npm: watch"
34 | 		}
35 | 	]
36 | }
37 | 


--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
 1 | // Place your settings in this file to overwrite default and user settings.
 2 | {
 3 |     "files.exclude": {
 4 |         "out": false // set this to true to hide the "out" folder with the compiled JS files
 5 |     },
 6 |     "search.exclude": {
 7 |         "out": true // set this to false to include "out" folder in search results
 8 |     },
 9 |     // Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10 |     "typescript.tsc.autoDetect": "off"
11 | }


--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
 1 | // See https://go.microsoft.com/fwlink/?LinkId=733558
 2 | // for the documentation about the tasks.json format
 3 | {
 4 | 	"version": "2.0.0",
 5 | 	"tasks": [
 6 | 		{
 7 | 			"type": "npm",
 8 | 			"script": "watch",
 9 | 			"problemMatcher": "$tsc-watch",
10 | 			"isBackground": true,
11 | 			"presentation": {
12 | 				"reveal": "never"
13 | 			},
14 | 			"group": {
15 | 				"kind": "build",
16 | 				"isDefault": true
17 | 			}
18 | 		}
19 | 	]
20 | }
21 | 


--------------------------------------------------------------------------------
/.vscodeignore:
--------------------------------------------------------------------------------
 1 | .vscode/**
 2 | .vscode-test/**
 3 | out/test/**
 4 | src/**
 5 | .gitignore
 6 | vsc-extension-quickstart.md
 7 | **/tsconfig.json
 8 | **/tslint.json
 9 | **/*.map
10 | **/*.ts
11 | **/node_modules


--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
  1 | # 更新日志
  2 | 🚀 [提交问题](https://github.com/any86/any-rule/issues/new)
  3 | 
  4 | ### 0.3.18(2022-11-07)
  5 | 
  6 | - 优化数字/货币金额(支持负数、千分位分隔符)
  7 | - 优化小数(支持科学计数)
  8 | - 优化缩短"用户名校验"正则长度
  9 | - 增加户口薄正则
 10 | - 增加军官证正则
 11 | - 修复MAC地址的第二位一定是偶数(#264)
 12 | 
 13 | ### 0.3.13(2022-01-10)
 14 | - 修正"网址"正则, 兼容更多符合的网址.
 15 | - 修正澳门身份证错误.
 16 | 
 17 | ### 0.3.12(2021-10-20)
 18 | - 修复网址中带有"()"不能通过.
 19 | - 新增"整数"/"浮点数"等正则.
 20 | 
 21 | ### 0.3.11(2021-09-26)
 22 | - 修复新版vscode中"@zz"字符失效.
 23 | - 优化"身份证15/18"正则.
 24 | 
 25 | ### 0.3.10(2021-05-28)
 26 | - 禁止"日期"可以通过"00"月和"00"日
 27 | ### 0.3.9(2021-04-20)
 28 | - 新增"GUID/UUID"正则.
 29 | - 修复ip中的"."没有被转义.
 30 | 
 31 | 
 32 | ### 0.3.8(2021-01-17)
 33 | - 优化一些冗余的正则拼写
 34 | - 修复新能源汽车不匹配第三位为字母的情况.
 35 | - 座机电话兼容带分机号的情况.
 36 | 
 37 | ### 0.3.7(2020-11-25)
 38 | - 修复"IPv4"不严格, 且增加端口校验.
 39 | - 新增"座机电话(区号可选)"
 40 | 
 41 | ### 0.3.6(2020-08-03)
 42 | - 新增"港澳台身份证"
 43 | 
 44 | ### 0.3.5(2020-07-18)
 45 | - 修复"车牌号"可以通过"浙苏H6F681"的问题
 46 | - 新增"数字和英文字母组成,并且同时含有数字和英文字母"
 47 | 
 48 | ### 0.3.4(2020-06-14)
 49 | - 修正"车牌号(新能源+非新能源)"未对长度进行限制.
 50 | - 修正"身份证"中月份可以匹配00月的bug.
 51 | - 新增"匹配连续重复的字符"正则.
 52 | - 修正座机支持4位区号,8位电话号.
 53 | - 修正, 根据用户需求, "qq@qq"样式的email邮箱地址不再通过验证.
 54 | 
 55 | ### 0.3.3(2020-04-28)
 56 | - 优化增加"身份证中日期的约束".
 57 | - 优化"html注释|座机|密码"等正则.
 58 | - 新增"mac地址"正则.
 59 | 
 60 | ### 0.3.2(2020-04-03)
 61 | - 修复"linux文件夹"正则不能匹配"/".
 62 | - 部分正则标题增加"英文关键字", 方便检索.
 63 | 
 64 | ### 0.3.1 (2020-03-12)
 65 | - 修复"@zz唤醒"和"菜单唤醒"在某些机型下失效的bug.
 66 | - 修复"设置后未生效".
 67 | - 修改部分提示图标.
 68 | - 合并'linux文件'和'linux文件夹'正则.
 69 | - 新增'linux隐藏文件'正则.
 70 | 
 71 | ### 0.3.0 (2020-02-28)
 72 | - 修改"zz."触发为"@zz"触发.
 73 | - 增加右键唤醒正则菜单.
 74 | ![](https://user-gold-cdn.xitu.io/2020/2/28/1708764046b38231?w=381&h=413&f=png&s=73047)
 75 | 
 76 | ### 0.2.0 (2020-02-21)
 77 | 
 78 | - 优化"zz."体验, 改用"quickPick"组件以支持"模糊搜索".
 79 | ![gif](https://user-gold-cdn.xitu.io/2020/2/23/1706df78b18466fd?w=954&h=372&f=gif&s=1732199)
 80 | - 增加"设置"功能, 可以在设置中搜索"any-rule".
 81 | - 新增"🦕图解正则".
 82 | ![](https://user-gold-cdn.xitu.io/2020/2/23/1706e32c3a6fb116?w=533&h=95&f=png&s=21563)
 83 | 
 84 | ![](https://user-gold-cdn.xitu.io/2020/2/23/1706e349b600c28b?w=1151&h=500&f=png&s=45210)
 85 | 
 86 | ### 0.1.0
 87 | - 新增支持在代码任意位置输入"zz."唤醒正则列表.
 88 | 
 89 | ### 0.0.13
 90 | - 给"统一社会信用代码"增加^$标记
 91 | - 修复图片/视频连接匹配不严谨
 92 | - 增加"机身码IMEI"正则
 93 | - 增加"火车车次"正则
 94 | 
 95 | ### 0.0.12
 96 | - 增加"必须带端口号的网址(或ip)"正则
 97 | - 修复网址可以匹配"...."的错误
 98 | 
 99 | ### 0.0.11
100 | - 增加"统一社会信用代码"正则
101 | 
102 | ### 0.0.10
103 | - 迅雷正则增加thunderx规则的支持
104 | 
105 | ### 0.0.9
106 | - 修复"ed2k"正则错误
107 | 
108 | ### 0.0.8
109 | - 优化车牌号正则
110 | 
111 | ### 0.0.7
112 | - 更新"银行卡"的匹配长度为10-30位,参考[微信支付](https://pay.weixin.qq.com/wiki/doc/api/xiaowei.php?chapter=22_1)
113 | 
114 | ### 0.0.6
115 | - 修复"手机号(严禁)正则"错误.
116 | 
117 | ### 0.0.5
118 | - 增加正则"迅雷链接" / "ed2k连接" / "磁力链接" / "子网掩码" / "linux文件(夹)路径" / "window文件(夹)路径"
119 | 
120 | 
121 | ### 0.0.4
122 | - 优化"大于0, 小于150, 支持小数位出现5"减少没必要的捕获
123 | - 修复"html注释"没有匹配换行符
124 | 
125 | ### 0.0.3
126 | 
127 | - 解决vscode低版本兼容问题
128 | - 替换主页的git图地址


--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
 1 | MIT License
 2 | 
 3 | Copyright (c) 2021 Russell
 4 | 
 5 | Permission is hereby granted, free of charge, to any person obtaining a copy
 6 | of this software and associated documentation files (the "Software"), to deal
 7 | in the Software without restriction, including without limitation the rights
 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 | 
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 | 
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | 


--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
  1 | # 正则大全  ![已收录84条](https://img.shields.io/badge/已收录-84条-673ab7.svg) [![版本](https://badgen.net/vs-marketplace/v/russell.any-rule)](https://marketplace.visualstudio.com/items?itemName=russell.any-rule) [![安装量](https://badgen.net/vs-marketplace/i/russell.any-rule)](https://marketplace.visualstudio.com/items?itemName=russell.any-rule) [![下载量](https://badgen.net/vs-marketplace/d/russell.any-rule)](https://marketplace.visualstudio.com/items?itemName=russell.any-rule) ![MIT](https://img.shields.io/badge/license-MIT-F44336.svg) [![CircleCI](https://badgen.net/github/status/any86/any-rule/master/ci/circleci)](https://circleci.com/gh/any86/any-rule)
  2 | 
  3 | 🦕支持**web** / **vscode** / **idea** / **Alfred Workflow**多平台
  4 | 
  5 | ## :rocket:web版本
  6 | https://any-rule.vercel.app/
  7 | 
  8 | ## 🍭vscode插件
  9 | 
 10 | ### 安装
 11 | vscode应用商店中搜索"**any-rule**".
 12 | 
 13 | ### 使用
 14 | **方式1:**
 15 | 
 16 | 1. 按**F1**(mac下fn+F1)打开正则列表.
 17 | 2. **输入关键词搜索**, 比如"手机".
 18 | 
 19 | ![GIF](https://user-images.githubusercontent.com/8264787/146724787-888a8666-5d2a-4e5e-b383-aec7c53bd312.gif)
 20 | 
 21 | **方式2:**
 22 | 
 23 | 右键选择"🦕正则大全".
 24 | 
 25 | ![GIF](https://user-images.githubusercontent.com/8264787/146725447-4d92caed-2dd0-4f11-91d1-8da9cd8ff08b.gif)
 26 | 
 27 | **方式3:**
 28 | 
 29 | 在代码任意位置输入"**@zz**".
 30 | 
 31 | ![GIF](https://user-images.githubusercontent.com/8264787/146725402-30b34119-b709-4d49-adb2-af8dbb786d3b.gif)
 32 | 
 33 | ## 👩‍🏫图解正则
 34 | <details>
 35 | <summary>查看详情</summary>
 36 | 每次在any-rule中选择正则后会弹出提示, 可点击"🤖图解正则".
 37 | 
 38 | ![image](https://user-images.githubusercontent.com/8264787/146726200-d97e48c3-df76-4531-8210-b6935fffb997.png)
 39 | 
 40 | 点击后可以看到正则解析, 方便大家学习.
 41 | 
 42 | ![image](https://user-images.githubusercontent.com/8264787/146726350-58166bf9-7f7f-4685-86aa-f055d0c0b914.png)
 43 | 
 44 | **注意**: 图解直接使用了https://regexper.com, 在此对作者表示敬意和感谢.
 45 | </details>
 46 | 
 47 | ## 社区版本
 48 | 
 49 | 社区版本非本人维护, 只是其他开发者使用了any-rule整理的正则内容, 如使用出现问题可直接与其开发者联系.
 50 | 
 51 | [idea版](https://github.com/zhoriya/idea-rule)
 52 | 
 53 | [Alfred Workflow版](https://github.com/cccyb/workflows)
 54 | 
 55 | [hyjs: 函数封装版](https://github.com/heiyehk/hyjs/tree/main/packages/utils)
 56 | 
 57 | [命令行版本](https://github.com/shenguanjiejie/workwork)
 58 | 
 59 | [uTools版本](https://github.com/trentlee0/utools-any-rule)
 60 | 
 61 | ## :fire:关于PR
 62 | 欢迎大家PR, 步骤如下:
 63 | 1. **正则**请在**packages/www/src/RULES.js**中添加.
 64 | 2. 运行`npm run test:rules`进行测试.
 65 | 3. 运行`npm run build:md`更新**README.md**.
 66 | 4. 请务必提交到**develop**分支.
 67 | 
 68 | 在此感谢大家对**any-rule**做出的贡献! 
 69 | 
 70 | ## 🍔正则
 71 | 
 72 | ### 火车车次
 73 | ```javascript
 74 | /^[GCDZTSPKXLY1-9]\d{1,4}$/
 75 | ```
 76 | 
 77 | ### 手机机身码(IMEI)
 78 | ```javascript
 79 | /^\d{15,17}$/
 80 | ```
 81 | 
 82 | ### 必须带端口号的网址(或ip)
 83 | ```javascript
 84 | /^((ht|f)tps?:\/\/)?[\w-]+(\.[\w-]+)+:\d{1,5}\/?$/
 85 | ```
 86 | 
 87 | ### 网址(URL)
 88 | ```javascript
 89 | /^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-]([^!@#$%^&*?.\s]{0,63}[^!@#$%^&*?.\s])?\.)+[a-z]{2,6}\/?/
 90 | ```
 91 | 
 92 | ### 统一社会信用代码
 93 | ```javascript
 94 | /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/
 95 | ```
 96 | 
 97 | ### 统一社会信用代码(宽松匹配)(15位/18位/20位数字/字母)
 98 | ```javascript
 99 | /^(([0-9A-Za-z]{15})|([0-9A-Za-z]{18})|([0-9A-Za-z]{20}))$/
100 | ```
101 | 
102 | ### 迅雷链接
103 | ```javascript
104 | /^thunderx?:\/\/[a-zA-Z\d]+=$/
105 | ```
106 | 
107 | ### ed2k链接(宽松匹配)
108 | ```javascript
109 | /^ed2k:\/\/\|file\|.+\|\/$/
110 | ```
111 | 
112 | ### 磁力链接(宽松匹配)
113 | ```javascript
114 | /^magnet:\?xt=urn:btih:[0-9a-fA-F]{40,}.*$/
115 | ```
116 | 
117 | ### 子网掩码(不包含 0.0.0.0)
118 | ```javascript
119 | /^(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)$/
120 | ```
121 | 
122 | ### linux"隐藏文件"路径
123 | ```javascript
124 | /^\/(?:[^/]+\/)*\.[^/]*/
125 | ```
126 | 
127 | ### linux文件夹路径
128 | ```javascript
129 | /^\/(?:[^/]+\/)*$/
130 | ```
131 | 
132 | ### linux文件路径
133 | ```javascript
134 | /^\/(?:[^/]+\/)*[^/]+$/
135 | ```
136 | 
137 | ### window"文件夹"路径
138 | ```javascript
139 | /^[a-zA-Z]:\\(?:\w+\\?)*$/
140 | ```
141 | 
142 | ### window下"文件"路径
143 | ```javascript
144 | /^[a-zA-Z]:\\(?:\w+\\)*\w+\.\w+$/
145 | ```
146 | 
147 | ### 股票代码(A股)
148 | ```javascript
149 | /^(s[hz]|S[HZ])(000[\d]{3}|002[\d]{3}|300[\d]{3}|600[\d]{3}|60[\d]{4})$/
150 | ```
151 | 
152 | ### 大于等于0, 小于等于150, 支持小数位出现5, 如145.5, 用于判断考卷分数
153 | ```javascript
154 | /^150$|^(?:\d|[1-9]\d|1[0-4]\d)(?:\.5)?$/
155 | ```
156 | 
157 | ### html注释
158 | ```javascript
159 | /<!--[\s\S]*?-->/g
160 | ```
161 | 
162 | ### md5格式(32位)
163 | ```javascript
164 | /^[a-fA-F0-9]{32}$/
165 | ```
166 | 
167 | ### GUID/UUID
168 | ```javascript
169 | /^[a-f\d]{4}(?:[a-f\d]{4}-){4}[a-f\d]{12}$/i
170 | ```
171 | 
172 | ### 版本号(version)格式必须为X.Y.Z
173 | ```javascript
174 | /^\d+(?:\.\d+){2}$/
175 | ```
176 | 
177 | ### 视频(video)链接地址(视频格式可按需增删)
178 | ```javascript
179 | /^https?:\/\/(.+\/)+.+(\.(swf|avi|flv|mpg|rm|mov|wav|asf|3gp|mkv|rmvb|mp4))$/i
180 | ```
181 | 
182 | ### 图片(image)链接地址(图片格式可按需增删)
183 | ```javascript
184 | /^https?:\/\/(.+\/)+.+(\.(gif|png|jpg|jpeg|webp|svg|psd|bmp|tif))$/i
185 | ```
186 | 
187 | ### 24小时制时间(HH:mm:ss)
188 | ```javascript
189 | /^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d$/
190 | ```
191 | 
192 | ### 12小时制时间(hh:mm:ss)
193 | ```javascript
194 | /^(?:1[0-2]|0?[1-9]):[0-5]\d:[0-5]\d$/
195 | ```
196 | 
197 | ### base64格式
198 | ```javascript
199 | /^\s*data:(?:[a-z]+\/[a-z0-9-+.]+(?:;[a-z-]+=[a-z0-9-]+)?)?(?:;base64)?,([a-z0-9!
amp;',()*+;=\-._~:@/?%\s]*?)\s*$/i
200 | ```
201 | 
202 | ### 数字/货币金额(支持负数、千分位分隔符)
203 | ```javascript
204 | /^-?\d{1,3}(,\d{3})*(\.\d{1,2})?$/
205 | ```
206 | 
207 | ### 银行卡号(10到30位, 覆盖对公/私账户, 参考[微信支付](https://pay.weixin.qq.com/wiki/doc/api/xiaowei.php?chapter=22_1))
208 | ```javascript
209 | /^[1-9]\d{9,29}$/
210 | ```
211 | 
212 | ### 中文姓名
213 | ```javascript
214 | /^(?:[\u4e00-\u9fa5·]{2,16})$/
215 | ```
216 | 
217 | ### 英文姓名
218 | ```javascript
219 | /(^[a-zA-Z][a-zA-Z\s]{0,20}[a-zA-Z]$)/
220 | ```
221 | 
222 | ### 车牌号(新能源)
223 | ```javascript
224 | /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z](([DF]((?![IO])[a-zA-Z0-9](?![IO]))[0-9]{4})|([0-9]{5}[DF]))$/
225 | ```
226 | 
227 | ### 车牌号(非新能源)
228 | ```javascript
229 | /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]$/
230 | ```
231 | 
232 | ### 车牌号(新能源+非新能源)
233 | ```javascript
234 | /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$/
235 | ```
236 | 
237 | ### 手机号(mobile phone)中国(严谨), 根据工信部2019年最新公布的手机号段
238 | ```javascript
239 | /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[01256789]))\d{8}$/
240 | ```
241 | 
242 | ### 手机号(mobile phone)中国(宽松), 只要是13,14,15,16,17,18,19开头即可
243 | ```javascript
244 | /^(?:(?:\+|00)86)?1[3-9]\d{9}$/
245 | ```
246 | 
247 | ### 手机号(mobile phone)中国(最宽松), 只要是1开头即可, 如果你的手机号是用来接收短信, 优先建议选择这一条
248 | ```javascript
249 | /^(?:(?:\+|00)86)?1\d{10}$/
250 | ```
251 | 
252 | ### 日期(宽松)
253 | ```javascript
254 | /^\d{1,4}(-)(1[0-2]|0?[1-9])\1(0?[1-9]|[1-2]\d|30|31)$/
255 | ```
256 | 
257 | ### 日期(严谨, 支持闰年判断)
258 | ```javascript
259 | /^(([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)$/
260 | ```
261 | 
262 | ### 中国省
263 | ```javascript
264 | /^浙江|上海|北京|天津|重庆|黑龙江|吉林|辽宁|内蒙古|河北|新疆|甘肃|青海|陕西|宁夏|河南|山东|山西|安徽|湖北|湖南|江苏|四川|贵州|云南|广西|西藏|江西|广东|福建|台湾|海南|香港|澳门$/
265 | ```
266 | 
267 | ### 可以被moment转化成功的时间 YYYYMMDD HH:mm:ss
268 | ```javascript
269 | /^\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$/
270 | ```
271 | 
272 | ### email(邮箱)
273 | ```javascript
274 | /^(([^<>()[\]\\.,;:\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,}))$/
275 | ```
276 | 
277 | ### 座机(tel phone)电话(国内),如: 0341-86091234
278 | ```javascript
279 | /^(?:(?:\d{3}-)?\d{8}|^(?:\d{4}-)?\d{7,8})(?:-\d+)?$/
280 | ```
281 | 
282 | ### 身份证号(1代,15位数字)
283 | ```javascript
284 | /^[1-9]\d{7}(?:0\d|10|11|12)(?:0[1-9]|[1-2][\d]|30|31)\d{3}$/
285 | ```
286 | 
287 | ### 身份证号(2代,18位数字),最后一位是校验位,可能为数字或字符X
288 | ```javascript
289 | /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/
290 | ```
291 | 
292 | ### 身份证号, 支持1/2代(15位/18位数字)
293 | ```javascript
294 | /^\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)$/
295 | ```
296 | 
297 | ### 护照(包含香港、澳门)
298 | ```javascript
299 | /(^[EeKkGgDdSsPpHh]\d{8}$)|(^(([Ee][a-fA-F])|([DdSsPp][Ee])|([Kk][Jj])|([Mm][Aa])|(1[45]))\d{7}$)/
300 | ```
301 | 
302 | ### 帐号是否合法(字母开头,允许5-16字节,允许字母数字下划线组合
303 | ```javascript
304 | /^[a-zA-Z]\w{4,15}$/
305 | ```
306 | 
307 | ### 中文/汉字
308 | ```javascript
309 | /^(?:[\u3400-\u4DB5\u4E00-\u9FEA\uFA0E\uFA0F\uFA11\uFA13\uFA14\uFA1F\uFA21\uFA23\uFA24\uFA27-\uFA29]|[\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0])+$/
310 | ```
311 | 
312 | ### 小数(支持科学计数)
313 | ```javascript
314 | /^[+-]?(\d+([.]\d*)?([eE][+-]?\d+)?|[.]\d+([eE][+-]?\d+)?)$/
315 | ```
316 | 
317 | ### 只包含数字
318 | ```javascript
319 | /^\d+$/
320 | ```
321 | 
322 | ### html标签(宽松匹配)
323 | ```javascript
324 | /<(\w+)[^>]*>(.*?<\/\1>)?/
325 | ```
326 | 
327 | ### 匹配中文汉字和中文标点
328 | ```javascript
329 | /[\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]/
330 | ```
331 | 
332 | ### qq号格式正确
333 | ```javascript
334 | /^[1-9][0-9]{4,10}$/
335 | ```
336 | 
337 | ### 数字和字母组成
338 | ```javascript
339 | /^[A-Za-z0-9]+$/
340 | ```
341 | 
342 | ### 英文字母
343 | ```javascript
344 | /^[a-zA-Z]+$/
345 | ```
346 | 
347 | ### 小写英文字母组成
348 | ```javascript
349 | /^[a-z]+$/
350 | ```
351 | 
352 | ### 大写英文字母
353 | ```javascript
354 | /^[A-Z]+$/
355 | ```
356 | 
357 | ### 密码强度校验,最少6位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符
358 | ```javascript
359 | /^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])(?=\S*[!@#$%^&*? ])\S*$/
360 | ```
361 | 
362 | ### 用户名校验,4到16位(字母,数字,下划线,减号)
363 | ```javascript
364 | /^[\w-]{4,16}$/
365 | ```
366 | 
367 | ### ip-v4[:端口]
368 | ```javascript
369 | /^((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(?::(?:[0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$/
370 | ```
371 | 
372 | ### ip-v6[:端口]
373 | ```javascript
374 | /(^(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$)|(^\[(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))\](?::(?:[0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$)/i
375 | ```
376 | 
377 | ### 16进制颜色
378 | ```javascript
379 | /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3}|[a-fA-F0-9]{8}|[a-fA-F0-9]{4})$/
380 | ```
381 | 
382 | ### 微信号(wx),6至20位,以字母开头,字母,数字,减号,下划线
383 | ```javascript
384 | /^[a-zA-Z][-_a-zA-Z0-9]{5,19}$/
385 | ```
386 | 
387 | ### 邮政编码(中国)
388 | ```javascript
389 | /^(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}$/
390 | ```
391 | 
392 | ### 中文和数字
393 | ```javascript
394 | /^((?:[\u3400-\u4DB5\u4E00-\u9FEA\uFA0E\uFA0F\uFA11\uFA13\uFA14\uFA1F\uFA21\uFA23\uFA24\uFA27-\uFA29]|[\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0])|(\d))+$/
395 | ```
396 | 
397 | ### 不能包含字母
398 | ```javascript
399 | /^[^A-Za-z]*$/
400 | ```
401 | 
402 | ### java包名
403 | ```javascript
404 | /^([a-zA-Z_]\w*)+([.][a-zA-Z_]\w*)+$/
405 | ```
406 | 
407 | ### mac地址
408 | ```javascript
409 | /^(([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
410 | ```
411 | 
412 | ### 匹配连续重复的字符
413 | ```javascript
414 | /(.)\1+/
415 | ```
416 | 
417 | ### 数字和英文字母组成,并且同时含有数字和英文字母
418 | ```javascript
419 | /^(?=.*[a-zA-Z])(?=.*\d).+$/
420 | ```
421 | 
422 | ### 香港身份证 
423 | ```javascript
424 | /^[a-zA-Z]\d{6}\([\dA]\)$/
425 | ```
426 | 
427 | ### 澳门身份证 
428 | ```javascript
429 | /^[1|5|7]\d{6}\(\d\)$/
430 | ```
431 | 
432 | ### 台湾身份证 
433 | ```javascript
434 | /^[a-zA-Z][0-9]{9}$/
435 | ```
436 | 
437 | ### 大写字母,小写字母,数字,特殊符号 `@#$%^&*`~()-+=` 中任意3项密码
438 | ```javascript
439 | /^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_!@#$%^&*`~()-+=]+$)(?![a-z0-9]+$)(?![a-z\W_!@#$%^&*`~()-+=]+$)(?![0-9\W_!@#$%^&*`~()-+=]+$)[a-zA-Z0-9\W_!@#$%^&*`~()-+=]/
440 | ```
441 | 
442 | ### ASCII码表中的全部的特殊字符
443 | ```javascript
444 | /[\x21-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E]+/
445 | ```
446 | 
447 | ### 正整数,不包含0
448 | ```javascript
449 | /^\+?[1-9]\d*$/
450 | ```
451 | 
452 | ### 负整数,不包含0
453 | ```javascript
454 | /^-[1-9]\d*$/
455 | ```
456 | 
457 | ### 整数
458 | ```javascript
459 | /^(?:0|(?:-?[1-9]\d*))$/
460 | ```
461 | 
462 | ### 浮点数
463 | ```javascript
464 | /^(-?[1-9]\d*\.\d+|-?0\.\d*[1-9]\d*|0\.0+)$/
465 | ```
466 | 
467 | ### 浮点数(严格)
468 | ```javascript
469 | /^(-?[1-9]\d*\.\d+|-?0\.\d*[1-9])$/
470 | ```
471 | 
472 | ### email(支持中文邮箱)
473 | ```javascript
474 | /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
475 | ```
476 | 
477 | ### 域名(非网址, 不包含协议)
478 | ```javascript
479 | /^([0-9a-zA-Z-]{1,}\.)+([a-zA-Z]{2,})$/
480 | ```
481 | 
482 | ### 军官/士兵证
483 | ```javascript
484 | /^[\u4E00-\u9FA5](字第)([0-9a-zA-Z]{4,8})(号?)$/
485 | ```
486 | 
487 | ### 户口薄
488 | ```javascript
489 | /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
490 | ```
491 | 


--------------------------------------------------------------------------------
/__test__/rule.js:
--------------------------------------------------------------------------------
 1 | const chalk = require('chalk');
 2 | const RULES = require('../packages/www/src/RULES');
 3 | let failGroup = [];
 4 | 
 5 | 
 6 | RULES.forEach(RULE => {
 7 |     testOne(RULE);
 8 | });
 9 | 
10 | 
11 | function testOne(one) {
12 |     const {
13 |         rule,
14 |         examples,
15 |         title,
16 |         counterExamples
17 |     } = one;
18 |     examples.forEach(example => {
19 |         const isSuccess = rule.test(example);
20 |         if (isSuccess) {
21 |             console.log(chalk.green(`成功: ${title}, 用例: ${example}`));
22 |         } else {
23 |             failGroup.push({title, example, is:'正例'});
24 |             
25 |             console.log(chalk.red(`失败: ${title}, 用例: ${example}`));
26 |         }
27 |     })
28 | 
29 |     if (counterExamples) {
30 |         counterExamples.forEach(example => {
31 |             const isFail = !rule.test(example);
32 |             if (isFail) {
33 |                 console.log(chalk.green(`反例成功(counterExamples): ${title}`));
34 |             } else {
35 |                 failGroup.push({title, example, is: '反例'});
36 |                 console.log(chalk.red(`反例失败(counterExamples): ${title}, 用例: ${example}`));
37 |             }
38 |         });
39 |     }
40 | }
41 | 
42 | if(0 === failGroup.length) {
43 |     console.log(chalk.green('\r\n🚀 全部测试通过!'))
44 | } else {
45 |     console.log(chalk.red('='.repeat(30) + '🔥 未通过测试' + '='.repeat(30)));
46 | 
47 |     // 失败列表
48 |     failGroup.forEach(item=>{
49 |         const str = `${item.title}[${item.is}]: ${item.example}`;
50 |         console.log(chalk.red(str));
51 |     });
52 | }
53 | 


--------------------------------------------------------------------------------
/images/vscode-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/any86/any-rule/43abe0f89526d0bfd4e53c2c83bb176216ab5645/images/vscode-logo.png


--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
  1 | {
  2 |     "name": "any-rule",
  3 |     "publisher": "russell",
  4 |     "displayName": "any-rule",
  5 |     "description": "你要的\"正则\"都在这!",
  6 |     "version": "0.3.18",
  7 |     "keywords": [
  8 |         "vscode",
  9 |         "typescript",
 10 |         "regxp",
 11 |         "正则"
 12 |     ],
 13 |     "husky": {
 14 |         "hooks": {
 15 |             "pre-push": "npm run test:rules"
 16 |         }
 17 |     },
 18 |     "scripts": {
 19 |         "build:md": "node ./scripts/md.js",
 20 |         "build": "npm run test:rules && npm version patch && node ./scripts/genCommond.js && vsce package --yarn && npm run build:md",
 21 |         "vscode:prepublish": "npm run compile",
 22 |         "compile": "webpack --mode production",
 23 |         "watch": "tsc -watch -p ./",
 24 |         "pretest": "npm run compile",
 25 |         "test": "node ./out/test/runTest.js",
 26 |         "test:rules": "node __test__/rule",
 27 |         "release:demo": "cd packages/www && yarn release",
 28 |         "dev:demo": "cd packages/www && yarn serve"
 29 |     },
 30 |     "engines": {
 31 |         "vscode": "^1.12.0"
 32 |     },
 33 |     "categories": [
 34 |         "Snippets",
 35 |         "Other"
 36 |     ],
 37 |     "icon": "images/vscode-logo.png",
 38 |     "bugs": {
 39 |         "url": "https://github.com/any86/any-rule/issues"
 40 |     },
 41 |     "repository": {
 42 |         "type": "git",
 43 |         "url": "https://github.com/any86/any-rule.git"
 44 |     },
 45 |     "activationEvents": [
 46 |         "*"
 47 |     ],
 48 |     "main": "./out/extension.js",
 49 |     "contributes": {
 50 |         "configuration": {
 51 |             "type": "object",
 52 |             "title": "any-rule",
 53 |             "properties": {
 54 |                 "any-rule.triggerString": {
 55 |                     "type": "string",
 56 |                     "default": "@zz",
 57 |                     "description": "触发字符串"
 58 |                 },
 59 |                 "any-rule.supportedLanguages": {
 60 |                     "type": "string",
 61 |                     "default": "*,javascript,javascriptreact,typescript,typescriptreact,vue,vue-postcss,vue-sugarss,vue-html,json,jsonc,graphql,dart,sql,go,java,php,jade,python,swift,markdown",
 62 |                     "description": "支持的开发语言(用','分割)"
 63 |                 }
 64 |             }
 65 |         },
 66 |         "menus": {
 67 |             "editor/context": [
 68 |                 {
 69 |                     "when": "editorFocus",
 70 |                     "command": "extension.rule.callByMenu",
 71 |                     "group": "navigation"
 72 |                 }
 73 |             ]
 74 |         },
 75 |         "commands": [
 76 |             {
 77 |                 "command": "extension.rule0",
 78 |                 "title": "$(rocket) zz: 火车车次"
 79 |             },
 80 |             {
 81 |                 "command": "extension.rule1",
 82 |                 "title": "$(rocket) zz: 手机机身码(IMEI)"
 83 |             },
 84 |             {
 85 |                 "command": "extension.rule2",
 86 |                 "title": "$(rocket) zz: 必须带端口号的网址(或ip)"
 87 |             },
 88 |             {
 89 |                 "command": "extension.rule3",
 90 |                 "title": "$(rocket) zz: 网址(URL)"
 91 |             },
 92 |             {
 93 |                 "command": "extension.rule4",
 94 |                 "title": "$(rocket) zz: 统一社会信用代码"
 95 |             },
 96 |             {
 97 |                 "command": "extension.rule5",
 98 |                 "title": "$(rocket) zz: 统一社会信用代码(宽松匹配)(15位/18位/20位数字/字母)"
 99 |             },
100 |             {
101 |                 "command": "extension.rule6",
102 |                 "title": "$(rocket) zz: 迅雷链接"
103 |             },
104 |             {
105 |                 "command": "extension.rule7",
106 |                 "title": "$(rocket) zz: ed2k链接(宽松匹配)"
107 |             },
108 |             {
109 |                 "command": "extension.rule8",
110 |                 "title": "$(rocket) zz: 磁力链接(宽松匹配)"
111 |             },
112 |             {
113 |                 "command": "extension.rule9",
114 |                 "title": "$(rocket) zz: 子网掩码(不包含 0.0.0.0)"
115 |             },
116 |             {
117 |                 "command": "extension.rule10",
118 |                 "title": "$(rocket) zz: linux\"隐藏文件\"路径"
119 |             },
120 |             {
121 |                 "command": "extension.rule11",
122 |                 "title": "$(rocket) zz: linux文件夹路径"
123 |             },
124 |             {
125 |                 "command": "extension.rule12",
126 |                 "title": "$(rocket) zz: linux文件路径"
127 |             },
128 |             {
129 |                 "command": "extension.rule13",
130 |                 "title": "$(rocket) zz: window\"文件夹\"路径"
131 |             },
132 |             {
133 |                 "command": "extension.rule14",
134 |                 "title": "$(rocket) zz: window下\"文件\"路径"
135 |             },
136 |             {
137 |                 "command": "extension.rule15",
138 |                 "title": "$(rocket) zz: 股票代码(A股)"
139 |             },
140 |             {
141 |                 "command": "extension.rule16",
142 |                 "title": "$(rocket) zz: 大于等于0, 小于等于150, 支持小数位出现5, 如145.5, 用于判断考卷分数"
143 |             },
144 |             {
145 |                 "command": "extension.rule17",
146 |                 "title": "$(rocket) zz: html注释"
147 |             },
148 |             {
149 |                 "command": "extension.rule18",
150 |                 "title": "$(rocket) zz: md5格式(32位)"
151 |             },
152 |             {
153 |                 "command": "extension.rule19",
154 |                 "title": "$(rocket) zz: GUID/UUID"
155 |             },
156 |             {
157 |                 "command": "extension.rule20",
158 |                 "title": "$(rocket) zz: 版本号(version)格式必须为X.Y.Z"
159 |             },
160 |             {
161 |                 "command": "extension.rule21",
162 |                 "title": "$(rocket) zz: 视频(video)链接地址(视频格式可按需增删)"
163 |             },
164 |             {
165 |                 "command": "extension.rule22",
166 |                 "title": "$(rocket) zz: 图片(image)链接地址(图片格式可按需增删)"
167 |             },
168 |             {
169 |                 "command": "extension.rule23",
170 |                 "title": "$(rocket) zz: 24小时制时间(HH:mm:ss)"
171 |             },
172 |             {
173 |                 "command": "extension.rule24",
174 |                 "title": "$(rocket) zz: 12小时制时间(hh:mm:ss)"
175 |             },
176 |             {
177 |                 "command": "extension.rule25",
178 |                 "title": "$(rocket) zz: base64格式"
179 |             },
180 |             {
181 |                 "command": "extension.rule26",
182 |                 "title": "$(rocket) zz: 数字/货币金额(支持负数、千分位分隔符)"
183 |             },
184 |             {
185 |                 "command": "extension.rule27",
186 |                 "title": "$(rocket) zz: 银行卡号(10到30位, 覆盖对公/私账户, 参考[微信支付](https://pay.weixin.qq.com/wiki/doc/api/xiaowei.php?chapter=22_1))"
187 |             },
188 |             {
189 |                 "command": "extension.rule28",
190 |                 "title": "$(rocket) zz: 中文姓名"
191 |             },
192 |             {
193 |                 "command": "extension.rule29",
194 |                 "title": "$(rocket) zz: 英文姓名"
195 |             },
196 |             {
197 |                 "command": "extension.rule30",
198 |                 "title": "$(rocket) zz: 车牌号(新能源)"
199 |             },
200 |             {
201 |                 "command": "extension.rule31",
202 |                 "title": "$(rocket) zz: 车牌号(非新能源)"
203 |             },
204 |             {
205 |                 "command": "extension.rule32",
206 |                 "title": "$(rocket) zz: 车牌号(新能源+非新能源)"
207 |             },
208 |             {
209 |                 "command": "extension.rule33",
210 |                 "title": "$(rocket) zz: 手机号(mobile phone)中国(严谨), 根据工信部2019年最新公布的手机号段"
211 |             },
212 |             {
213 |                 "command": "extension.rule34",
214 |                 "title": "$(rocket) zz: 手机号(mobile phone)中国(宽松), 只要是13,14,15,16,17,18,19开头即可"
215 |             },
216 |             {
217 |                 "command": "extension.rule35",
218 |                 "title": "$(rocket) zz: 手机号(mobile phone)中国(最宽松), 只要是1开头即可, 如果你的手机号是用来接收短信, 优先建议选择这一条"
219 |             },
220 |             {
221 |                 "command": "extension.rule36",
222 |                 "title": "$(rocket) zz: 日期(宽松)"
223 |             },
224 |             {
225 |                 "command": "extension.rule37",
226 |                 "title": "$(rocket) zz: 日期(严谨, 支持闰年判断)"
227 |             },
228 |             {
229 |                 "command": "extension.rule38",
230 |                 "title": "$(rocket) zz: 中国省"
231 |             },
232 |             {
233 |                 "command": "extension.rule39",
234 |                 "title": "$(rocket) zz: 可以被moment转化成功的时间 YYYYMMDD HH:mm:ss"
235 |             },
236 |             {
237 |                 "command": "extension.rule40",
238 |                 "title": "$(rocket) zz: email(邮箱)"
239 |             },
240 |             {
241 |                 "command": "extension.rule41",
242 |                 "title": "$(rocket) zz: 座机(tel phone)电话(国内),如: 0341-86091234"
243 |             },
244 |             {
245 |                 "command": "extension.rule42",
246 |                 "title": "$(rocket) zz: 身份证号(1代,15位数字)"
247 |             },
248 |             {
249 |                 "command": "extension.rule43",
250 |                 "title": "$(rocket) zz: 身份证号(2代,18位数字),最后一位是校验位,可能为数字或字符X"
251 |             },
252 |             {
253 |                 "command": "extension.rule44",
254 |                 "title": "$(rocket) zz: 身份证号, 支持1/2代(15位/18位数字)"
255 |             },
256 |             {
257 |                 "command": "extension.rule45",
258 |                 "title": "$(rocket) zz: 护照(包含香港、澳门)"
259 |             },
260 |             {
261 |                 "command": "extension.rule46",
262 |                 "title": "$(rocket) zz: 帐号是否合法(字母开头,允许5-16字节,允许字母数字下划线组合"
263 |             },
264 |             {
265 |                 "command": "extension.rule47",
266 |                 "title": "$(rocket) zz: 中文/汉字"
267 |             },
268 |             {
269 |                 "command": "extension.rule48",
270 |                 "title": "$(rocket) zz: 小数(支持科学计数)"
271 |             },
272 |             {
273 |                 "command": "extension.rule49",
274 |                 "title": "$(rocket) zz: 只包含数字"
275 |             },
276 |             {
277 |                 "command": "extension.rule50",
278 |                 "title": "$(rocket) zz: html标签(宽松匹配)"
279 |             },
280 |             {
281 |                 "command": "extension.rule51",
282 |                 "title": "$(rocket) zz: 匹配中文汉字和中文标点"
283 |             },
284 |             {
285 |                 "command": "extension.rule52",
286 |                 "title": "$(rocket) zz: qq号格式正确"
287 |             },
288 |             {
289 |                 "command": "extension.rule53",
290 |                 "title": "$(rocket) zz: 数字和字母组成"
291 |             },
292 |             {
293 |                 "command": "extension.rule54",
294 |                 "title": "$(rocket) zz: 英文字母"
295 |             },
296 |             {
297 |                 "command": "extension.rule55",
298 |                 "title": "$(rocket) zz: 小写英文字母组成"
299 |             },
300 |             {
301 |                 "command": "extension.rule56",
302 |                 "title": "$(rocket) zz: 大写英文字母"
303 |             },
304 |             {
305 |                 "command": "extension.rule57",
306 |                 "title": "$(rocket) zz: 密码强度校验,最少6位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符"
307 |             },
308 |             {
309 |                 "command": "extension.rule58",
310 |                 "title": "$(rocket) zz: 用户名校验,4到16位(字母,数字,下划线,减号)"
311 |             },
312 |             {
313 |                 "command": "extension.rule59",
314 |                 "title": "$(rocket) zz: ip-v4[:端口]"
315 |             },
316 |             {
317 |                 "command": "extension.rule60",
318 |                 "title": "$(rocket) zz: ip-v6[:端口]"
319 |             },
320 |             {
321 |                 "command": "extension.rule61",
322 |                 "title": "$(rocket) zz: 16进制颜色"
323 |             },
324 |             {
325 |                 "command": "extension.rule62",
326 |                 "title": "$(rocket) zz: 微信号(wx),6至20位,以字母开头,字母,数字,减号,下划线"
327 |             },
328 |             {
329 |                 "command": "extension.rule63",
330 |                 "title": "$(rocket) zz: 邮政编码(中国)"
331 |             },
332 |             {
333 |                 "command": "extension.rule64",
334 |                 "title": "$(rocket) zz: 中文和数字"
335 |             },
336 |             {
337 |                 "command": "extension.rule65",
338 |                 "title": "$(rocket) zz: 不能包含字母"
339 |             },
340 |             {
341 |                 "command": "extension.rule66",
342 |                 "title": "$(rocket) zz: java包名"
343 |             },
344 |             {
345 |                 "command": "extension.rule67",
346 |                 "title": "$(rocket) zz: mac地址"
347 |             },
348 |             {
349 |                 "command": "extension.rule68",
350 |                 "title": "$(rocket) zz: 匹配连续重复的字符"
351 |             },
352 |             {
353 |                 "command": "extension.rule69",
354 |                 "title": "$(rocket) zz: 数字和英文字母组成,并且同时含有数字和英文字母"
355 |             },
356 |             {
357 |                 "command": "extension.rule70",
358 |                 "title": "$(rocket) zz: 香港身份证 "
359 |             },
360 |             {
361 |                 "command": "extension.rule71",
362 |                 "title": "$(rocket) zz: 澳门身份证 "
363 |             },
364 |             {
365 |                 "command": "extension.rule72",
366 |                 "title": "$(rocket) zz: 台湾身份证 "
367 |             },
368 |             {
369 |                 "command": "extension.rule73",
370 |                 "title": "$(rocket) zz: 大写字母,小写字母,数字,特殊符号 `@#$%^&*`~()-+=` 中任意3项密码"
371 |             },
372 |             {
373 |                 "command": "extension.rule74",
374 |                 "title": "$(rocket) zz: ASCII码表中的全部的特殊字符"
375 |             },
376 |             {
377 |                 "command": "extension.rule75",
378 |                 "title": "$(rocket) zz: 正整数,不包含0"
379 |             },
380 |             {
381 |                 "command": "extension.rule76",
382 |                 "title": "$(rocket) zz: 负整数,不包含0"
383 |             },
384 |             {
385 |                 "command": "extension.rule77",
386 |                 "title": "$(rocket) zz: 整数"
387 |             },
388 |             {
389 |                 "command": "extension.rule78",
390 |                 "title": "$(rocket) zz: 浮点数"
391 |             },
392 |             {
393 |                 "command": "extension.rule79",
394 |                 "title": "$(rocket) zz: 浮点数(严格)"
395 |             },
396 |             {
397 |                 "command": "extension.rule80",
398 |                 "title": "$(rocket) zz: email(支持中文邮箱)"
399 |             },
400 |             {
401 |                 "command": "extension.rule81",
402 |                 "title": "$(rocket) zz: 域名(非网址, 不包含协议)"
403 |             },
404 |             {
405 |                 "command": "extension.rule82",
406 |                 "title": "$(rocket) zz: 军官/士兵证"
407 |             },
408 |             {
409 |                 "command": "extension.rule83",
410 |                 "title": "$(rocket) zz: 户口薄"
411 |             },
412 |             {
413 |                 "command": "extension.rule.callByMenu",
414 |                 "title": "🦕正则大全(84条)"
415 |             }
416 |         ]
417 |     },
418 |     "devDependencies": {
419 |         "@types/glob": "^7.1.1",
420 |         "@types/mocha": "^5.2.6",
421 |         "@types/node": "^10.12.21",
422 |         "@types/vscode": "^1.12.0",
423 |         "glob": "^7.1.4",
424 |         "husky": "^4.2.5",
425 |         "mocha": "^6.1.4",
426 |         "qiniu-js": "^2.5.5",
427 |         "ts-loader": "^6.2.1",
428 |         "tslint": "^5.12.1",
429 |         "typescript": "^3.3.1",
430 |         "vsce": "^1.74.0",
431 |         "vscode-test": "^1.0.2",
432 |         "webpack": "^4.41.6",
433 |         "webpack-cli": "^3.3.11"
434 |     },
435 |     "dependencies": {
436 |         "axios": "^0.19.2",
437 |         "transliteration": "^2.1.8"
438 |     }
439 | }


--------------------------------------------------------------------------------
/packages/www/.gitignore:
--------------------------------------------------------------------------------
 1 | .DS_Store
 2 | node_modules
 3 | /dist
 4 | 
 5 | # local env files
 6 | .env.local
 7 | .env.*.local
 8 | 
 9 | # Log files
10 | npm-debug.log*
11 | yarn-debug.log*
12 | yarn-error.log*
13 | 
14 | # Editor directories and files
15 | .idea
16 | .vscode
17 | *.suo
18 | *.ntvs*
19 | *.njsproj
20 | *.sln
21 | *.sw?
22 | 


--------------------------------------------------------------------------------
/packages/www/LICENSE:
--------------------------------------------------------------------------------
 1 | MIT License
 2 | 
 3 | Copyright (c) 2019 any86
 4 | 
 5 | Permission is hereby granted, free of charge, to any person obtaining a copy
 6 | of this software and associated documentation files (the "Software"), to deal
 7 | in the Software without restriction, including without limitation the rights
 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 | 
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 | 
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | 


--------------------------------------------------------------------------------
/packages/www/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 |   presets: [
3 |     '@vue/app'
4 |   ]
5 | }
6 | 


--------------------------------------------------------------------------------
/packages/www/package.json:
--------------------------------------------------------------------------------
 1 | {
 2 |   "name": "any-rule",
 3 |   "version": "0.1.0",
 4 |   "private": true,
 5 |   "scripts": {
 6 |     "serve": "vue-cli-service serve",
 7 |     "build": "vue-cli-service build",
 8 |     "release": "npm run build && node ./scripts/demo",
 9 |     "lint": "vue-cli-service lint",
10 |     "rm:nm":"rimraf node_modules"
11 |   },
12 |   "dependencies": {
13 |     "clipboard": "^2.0.4",
14 |     "core-js": "^2.6.5",
15 |     "crypto-js": "^4.0.0",
16 |     "lodash": "^4.17.13",
17 |     "node-sass": "^6.0.0",
18 |     "sass-loader": "^10.0.0",
19 |     "vue": "^2.6.10"
20 |   },
21 |   "devDependencies": {
22 |     "@vue/cli-plugin-babel": "^3.8.0",
23 |     "@vue/cli-plugin-eslint": "^3.8.0",
24 |     "@vue/cli-service": "^3.8.0",
25 |     "chalk": "^2.4.2",
26 |     "gh-pages": "^2.0.1",
27 |     "shelljs": "^0.8.3",
28 |     "vue-template-compiler": "^2.6.10"
29 |   },
30 |   "eslintConfig": {
31 |     "root": true,
32 |     "env": {
33 |       "node": true
34 |     },
35 |     "extends": [
36 |       "plugin:vue/essential",
37 |       "eslint:recommended"
38 |     ],
39 |     "rules": {},
40 |     "parserOptions": {
41 |       "parser": "babel-eslint"
42 |     }
43 |   },
44 |   "postcss": {
45 |     "plugins": {
46 |       "autoprefixer": {}
47 |     }
48 |   },
49 |   "browserslist": [
50 |     "> 1%",
51 |     "last 2 versions"
52 |   ]
53 | }
54 | 


--------------------------------------------------------------------------------
/packages/www/prettier.config.js:
--------------------------------------------------------------------------------
1 | // prettier.config.js or .prettierrc.js
2 | module.exports = {
3 |     tabWidth: 4,
4 |     semi: true,
5 |     singleQuote: true,
6 |     arrowParens: 'always',
7 |     printWidth: 120
8 | };


--------------------------------------------------------------------------------
/packages/www/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/any86/any-rule/43abe0f89526d0bfd4e53c2c83bb176216ab5645/packages/www/public/favicon.ico


--------------------------------------------------------------------------------
/packages/www/public/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/any86/any-rule/43abe0f89526d0bfd4e53c2c83bb176216ab5645/packages/www/public/icon.png


--------------------------------------------------------------------------------
/packages/www/public/index.html:
--------------------------------------------------------------------------------
 1 | <!DOCTYPE html>
 2 | <html lang="en">
 3 | 
 4 | <head>
 5 |     <meta charset="utf-8">
 6 |     <meta http-equiv="X-UA-Compatible" content="IE=edge">
 7 |     <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
 8 |     <link rel="icon" href="<%= BASE_URL %>favicon.ico">
 9 |     <link rel="manifest" href="<%= BASE_URL %>manifest.json">
10 |     <title>正则大全</title>
11 |     <!-- 百度统计 -->
12 |     <script>
13 |         var _hmt = _hmt || [];
14 |         (function() {
15 |             var hm = document.createElement("script");
16 |             hm.src = "https://hm.baidu.com/hm.js?0a8aba0d0567d5e3b7fa2c9eac9d781f";
17 |             var s = document.getElementsByTagName("script")[0];
18 |             s.parentNode.insertBefore(hm, s);
19 |         })();
20 |     </script>
21 |     <!-- <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.8/styles/github.min.css">
22 |     <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.8/highlight.min.js"></script> -->
23 |     <style>
24 |         :root {
25 |             --primary: #42b983;
26 |         }
27 | 
28 |         * {
29 |             padding: 0;
30 |             margin: 0;
31 |             box-sizing: border-box;
32 |         }
33 | 
34 |         body {
35 |             overflow-x: hidden;
36 |             overflow-y: scroll;
37 |         }
38 | 
39 |         a {
40 |             text-decoration: none;
41 |         }
42 | 
43 |         input {
44 |             outline: none;
45 |             border: 0 none;
46 |         }
47 | 
48 |         li {
49 |             list-style-type: none;
50 |         }
51 | 
52 |         @keyframes rotate {
53 |             from {
54 |                 transform: rotate(0);
55 |             }
56 | 
57 |             to {
58 |                 transform: rotate(360deg);
59 |             }
60 |         }
61 | 
62 |         .loading {
63 |             animation: rotate 1s infinite linear;
64 |             margin: 0;
65 |             padding: 0;
66 |             position: fixed;
67 |             top: 0;
68 |             left: 0;
69 |             right: 0;
70 |             bottom: 0;
71 |             margin: auto;
72 |             display: block;
73 |             width: 100px;
74 |             height: 100px;
75 |             border: 0 solid #42b983;
76 |             border-right-width: 4px;
77 |             border-radius: 50%;
78 |         }
79 |     </style>
80 | </head>
81 | 
82 | <body>
83 |     <noscript>
84 |         <strong>We're sorry but any-rule doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
85 |     </noscript>
86 | 
87 |     <div id="app">
88 |         <i class="loading"></i>
89 |     </div>
90 |     <!-- built files will be auto injected -->
91 | </body>
92 | 
93 | </html>


--------------------------------------------------------------------------------
/packages/www/public/manifest.json:
--------------------------------------------------------------------------------
 1 | {
 2 |     "short_name": "any-rule",
 3 |     "name": "正则大全",
 4 |     "icons": [
 5 |         {
 6 |             "src": "/any-rule/icon.png",
 7 |             "type": "image/png",
 8 |             "sizes": "192x192"
 9 |         }
10 |     ],
11 |     "background_color": "#2196F3",
12 |     "theme_color": "#2196F3",
13 |     "display": "standalone",
14 |     "start_url": "/any-rule"
15 | }


--------------------------------------------------------------------------------
/packages/www/public/sw.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/any86/any-rule/43abe0f89526d0bfd4e53c2c83bb176216ab5645/packages/www/public/sw.js


--------------------------------------------------------------------------------
/packages/www/scripts/demo.js:
--------------------------------------------------------------------------------
 1 | var ghpages = require('gh-pages');
 2 | const shell = require('shelljs');
 3 | const chalk = require('chalk');
 4 | 
 5 | // 发布
 6 | ghpages.publish('./dist', {
 7 |     branch: 'gh-pages',
 8 | }, (err) => {
 9 |     if(err) {
10 |         console.log(chalk.red(err));
11 |     } else {
12 |         shell.rm('-rf', './dist');
13 |         console.log(chalk.green('demo同步完成!'));
14 |     }
15 | });


--------------------------------------------------------------------------------
/packages/www/src/App.vue:
--------------------------------------------------------------------------------
  1 | <template>
  2 |     <main>
  3 |         <article class="fixed">
  4 |             <a
  5 |                 onclick="_hmt.push(['_trackEvent', '交互', '提问'])"
  6 |                 class="message"
  7 |                 href="https://github.com/any86/any-rule/issues/new"
  8 |                 target="_blank"
  9 |                 ><svg
 10 |                     style="margin-right: 8px"
 11 |                     height="24"
 12 |                     width="24"
 13 |                     viewBox="0 0 16 16"
 14 |                     version="1.1"
 15 |                     aria-hidden="true"
 16 |                 >
 17 |                     <path
 18 |                         fill-rule="evenodd"
 19 |                         fill="#fff"
 20 |                         d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"
 21 |                     ></path>
 22 |                 </svg>
 23 |                 提问</a
 24 |             >
 25 |         </article>
 26 |         <header>
 27 |             <a
 28 |                 onclick="_hmt.push(['_trackEvent', '交互', '点击github', '头部'])"
 29 |                 href="https://github.com/any86/any-rule"
 30 |                 target="_blank"
 31 |                 class="github"
 32 |             >
 33 |                 <!-- <svg height="32" viewBox="0 0 16 16" version="1.1" width="32" aria-hidden="true">
 34 |                     <path
 35 |                         fill-rule="evenodd"
 36 |                         d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"
 37 |                     ></path>
 38 |                 </svg> -->
 39 |                 <h1>🦕正则大全</h1>
 40 |             </a>
 41 | 
 42 |             <iframe
 43 |                 style="display: block; margin-top: 15px"
 44 |                 src="https://ghbtns.com/github-btn.html?user=any86&repo=any-rule&type=star&count=true"
 45 |                 frameborder="0"
 46 |                 scrolling="0"
 47 |                 width="170px"
 48 |                 height="20px"
 49 |             ></iframe>
 50 | 
 51 |             <input
 52 |                 ref="searchInput"
 53 |                 v-model="keyword"
 54 |                 autofocus
 55 |                 @keyup="search"
 56 |                 @mouseenter="selectSearchInputText"
 57 |                 @focus="selectSearchInputText"
 58 |                 class="search-input"
 59 |                 placeholder="搜索关键词, 如'手机'"
 60 |                 type="text"
 61 |             />
 62 |         </header>
 63 | 
 64 |         <article>
 65 |             <ul v-if="0 < rules.length" class="list">
 66 |                 <li
 67 |                     @mouseenter="mouseenterHandler(index)"
 68 |                     v-for="({ title, rule, events, examples, counterExamples }, index) in rules"
 69 |                     :key="title"
 70 |                     class="row"
 71 |                 >
 72 |                     <i class="border"></i>
 73 |                     <h2>{{ title }}</h2>
 74 |                     <p class="rule">
 75 |                         <span :data-clipboard-text="rule" class="btn-copy">点击复制</span>
 76 |                         <a
 77 |                             :href="`https://github.com/any86/any-rule/issues/new?title=我有更好的正则: ${title}`"
 78 |                             target="_blank"
 79 |                             class="btn-better"
 80 |                             >我有更好的正则</a
 81 |                         >
 82 |                         <code ref="code" class="javascript">{{ rule }}</code>
 83 |                     </p>
 84 |                     <section class="verification">
 85 |                         <label>
 86 |                             <input
 87 |                                 ref="input"
 88 |                                 :key="title"
 89 |                                 v-model="list[index].value"
 90 |                                 :placeholder="parseExample(examples, counterExamples)"
 91 |                                 @compositionstart="check(index, 'blur')"
 92 |                                 @compositionupdate="check(index, 'blur')"
 93 |                                 @compositionend="check(index, 'blur')"
 94 |                                 @blur="check(index, 'blur')"
 95 |                                 @keyup="check(index, 'keyup')"
 96 |                             />
 97 |                             <span class="btn-clear" @click="reset(index)">清空</span>
 98 |                         </label>
 99 | 
100 |                         <div class="tip">
101 |                             <template v-if="undefined !== list[index].isOk">
102 |                                 <p v-if="list[index].isOk" class="success">通过</p>
103 |                                 <p v-else class="error">不通过</p>
104 |                             </template>
105 |                         </div>
106 |                     </section>
107 | 
108 |                     <section class="trigger">
109 |                         <h3>验证时机</h3>
110 |                         <label> <input v-model="list[index].events.blur" type="checkbox" /> blur </label>
111 | 
112 |                         <label> <input v-model="list[index].events.keyup" type="checkbox" /> keyup </label>
113 |                     </section>
114 |                 </li>
115 |             </ul>
116 |             <p v-else align="center">无数据</p>
117 |         </article>
118 |     </main>
119 | </template>
120 | 
121 | <script>
122 | import RULES from '@/RULES';
123 | import ClipboardJS from 'clipboard';
124 | export default {
125 |     name: 'app',
126 | 
127 |     components: {},
128 | 
129 |     data() {
130 |         Object.freeze(RULES);
131 | 
132 |         return {
133 |             token: '',
134 |             timer: null,
135 |             keyword: '',
136 |             rules: RULES,
137 |             list: RULES.map(() => ({
138 |                 value: '',
139 |                 isOk: undefined,
140 |                 events: {
141 |                     blur: true,
142 |                     keyup: true,
143 |                 },
144 |             })),
145 |         };
146 |     },
147 | 
148 |     mounted() {
149 |         // this.$nextTick(() => {
150 |         //     // 高亮
151 |         //     this.$refs.code.forEach((block) => {
152 |         //         console.log(block);
153 |         //         /* eslint-disable */
154 |         //         hljs.highlightBlock(block);
155 |         //     });
156 |         // });
157 | 
158 |         const clipboard = new ClipboardJS('.btn-copy');
159 | 
160 |         this.$on('hook:destroyed', () => {
161 |             clipboard.destroy();
162 |         });
163 |         let timer = null;
164 |         clipboard.on('success', (e) => {
165 |             clearTimeout(timer);
166 |             const el = e.trigger;
167 |             if (el.classList.contains('success')) {
168 |                 el.classList.remove('success');
169 |             }
170 |             el.classList.add('success');
171 |             timer = setTimeout(() => {
172 |                 el.classList.remove('success');
173 |             }, 1000);
174 |         });
175 |     },
176 | 
177 |     methods: {
178 |         parseExample(examples, counterExamples) {
179 |             let arr = [`例如: ${examples.join(', ')}`];
180 |             if (undefined !== counterExamples) {
181 |                 arr.push(`反例: ${counterExamples.join(', ')}`);
182 |             }
183 |             return arr.join(' , ');
184 |         },
185 | 
186 |         search() {
187 |             if ('' !== this.keyword) {
188 |                 this.rules = this.rules.filter(({ title }) => -1 !== title.toLowerCase().indexOf(this.keyword.toLowerCase()));
189 |             } else {
190 |                 this.rules = RULES;
191 |             }
192 |             /* eslint-disable */
193 |             _hmt.push(['_trackEvent', '交互', '搜索', '关键词', this.keyword]);
194 |         },
195 | 
196 |         selectSearchInputText() {
197 |             this.$refs.searchInput.select();
198 |         },
199 | 
200 |         autoFocus(index) {
201 |             this.$refs.input[index].focus();
202 |         },
203 |         /* eslint-disable */
204 |         mouseenterHandler(index) {},
205 | 
206 |         // mouseenterHandler: throttle((index)=>{
207 |         //    this.$refs.input[index].focus();
208 |         // },1000).bind(this),
209 | 
210 |         reset(index) {
211 |             this.$nextTick(() => {
212 |                 this.list[index].value = '';
213 |                 this.list[index].isOk = undefined;
214 |             });
215 |         },
216 | 
217 |         check(index, type) {
218 |             const { events, value } = this.list[index];
219 |             if ('' === value) this.reset(index);
220 |             if (events[type]) {
221 |                 const { rule } = this.rules[index];
222 |                 const row = this.list[index];
223 |                 row.isOk = rule.test(row.value);
224 |             }
225 | 
226 |             if ('blur' === type) {
227 |                 /* eslint-disable */
228 |                 _hmt.push(['_trackEvent', 'input框', this.rules[index].title, this.list[index].value]);
229 |             }
230 |         },
231 |     },
232 | };
233 | </script>
234 | 
235 | <style lang="scss" scoped>
236 | $primary: #42b983;
237 | $danger: #ec5c51;
238 | 
239 | $radius: 4px;
240 | @keyframes slide {
241 |     from {
242 |         top: 0;
243 |     }
244 |     to {
245 |         top: 100px;
246 |     }
247 | }
248 | 
249 | @keyframes shrinkBorder {
250 |     from {
251 |         transform: translateY(-100%);
252 |     }
253 |     50% {
254 |         width: 4px;
255 |         opacity: 0.62;
256 |     }
257 | 
258 |     to {
259 |         left: 0;
260 |         transform: translateY(0);
261 |     }
262 | }
263 | main {
264 |     font-family: 'Avenir', Helvetica, Arial, sans-serif;
265 |     -webkit-font-smoothing: antialiased;
266 |     -moz-osx-font-smoothing: grayscale;
267 |     max-width: 1000px;
268 |     width: 100%;
269 |     margin: auto;
270 | 
271 |     .fixed {
272 |         position: fixed;
273 |         z-index: 1986;
274 |         right: 15px;
275 |         bottom: 15px;
276 |         > a {
277 |             display: flex;
278 |             border-radius: $radius;
279 |             align-content: center;
280 |             align-items: center;
281 |             justify-content: center;
282 |             justify-items: center;
283 |             font-size: 16px;
284 |             text-align: center;
285 |             padding: 16px;
286 |             box-shadow: 1px 2px 3px 1px rgba(0, 0, 0, 0.1);
287 |             &:active {
288 |                 opacity: 0.6;
289 |                 box-shadow: none;
290 |             }
291 |             &:hover {
292 |                 opacity: 0.6;
293 |             }
294 |             &.github {
295 |                 background: rgba(#eee, 0.9);
296 |                 > span {
297 |                     color: #000;
298 |                     padding: 0 10px;
299 |                 }
300 |             }
301 |             &.message {
302 |                 background: rgba($primary, 0.9);
303 |                 color: #fff;
304 |             }
305 |         }
306 |     }
307 | 
308 |     header {
309 |         padding: 15px;
310 |         position: sticky;
311 |         top: 0;
312 |         z-index: 99;
313 |         background: linear-gradient(180deg, white 80%, transparent);
314 |         > .search-input {
315 |             display: block;
316 |             margin-top: 15px;
317 |             font-size: 16px;
318 |             border: 1px solid #ddd;
319 |             width: 100%;
320 |             padding: 15px;
321 |             border-radius: $radius;
322 |             box-shadow: 1px 2px 2px rgba(0, 0, 0, 0.1);
323 |         }
324 | 
325 |         // 标题
326 |         > .github {
327 |             display: inline-flex;
328 |             align-items: center;
329 |             color: #000;
330 | 
331 |             h1 {
332 |                 margin-left: 8px;
333 |             }
334 |         }
335 |     }
336 |     ul.list {
337 |         padding: 15px;
338 |         li {
339 |             position: relative;
340 |             overflow: hidden;
341 |             border-radius: $radius;
342 |             margin-bottom: 15px;
343 |             padding: 15px;
344 |             border-color: #eee;
345 |             border-width: 1px;
346 |             border-style: solid;
347 |             box-shadow: 1px 2px 5px 1px rgba(0, 0, 0, 0.1);
348 |             > .border {
349 |                 position: absolute;
350 |                 background: $primary;
351 |                 width: 4px;
352 |                 height: 100%;
353 |                 top: 0;
354 |                 left: -4px;
355 |             }
356 |             &:hover {
357 |                 background-color: #ddd;
358 |                 transition: all 600ms;
359 |                 border-radius: $radius;
360 |                 border-color: #eee;
361 |                 box-shadow: none;
362 |                 > .border {
363 |                     animation: shrinkBorder 0.5s;
364 |                     left: 0;
365 |                 }
366 |             }
367 |             > p.rule {
368 |                 margin-top: 15px;
369 |                 padding: 5px 15px;
370 |                 background: #eee;
371 |                 color: #000;
372 |                 border-radius: $radius;
373 |                 line-height: 2;
374 |                 > .btn-copy {
375 |                     display: inline-block;
376 |                     border-radius: $radius;
377 |                     margin-right: 15px;
378 |                     padding: 0 5px;
379 |                     background: $primary;
380 |                     color: #fff;
381 |                     font-size: 12px;
382 |                     cursor: pointer;
383 |                     box-shadow: 1px 2px 3px $primary;
384 |                     &.success {
385 |                         &:after {
386 |                             content: '复制成功';
387 |                             border-radius: $radius;
388 |                             display: block;
389 |                             padding: 5px 15px;
390 |                             background: rgba(0, 0, 0, 0.8);
391 |                             color: #fff;
392 |                             text-align: center;
393 |                             position: absolute;
394 |                         }
395 |                     }
396 |                     &:active {
397 |                         opacity: 0.6;
398 |                         box-shadow: none;
399 |                     }
400 | 
401 |                     &:hover {
402 |                         transition: all 0.3s;
403 |                         color: rgba(255, 255, 255, 0.6)
404 |                     }
405 |                 }
406 | 
407 |                 > .btn-better {
408 |                     @extend .btn-copy;
409 |                     background-color: $danger;
410 |                     box-shadow: 1px 2px 3px $danger;
411 |                 }
412 | 
413 |                 > code {
414 |                     word-break: break-word;
415 |                 }
416 |             }
417 | 
418 |             > section.verification {
419 |                 margin-top: 15px;
420 |                 overflow: hidden;
421 |                 > label {
422 |                     display: flex;
423 |                     > input {
424 |                         flex-grow: 1;
425 |                         padding: 5px 15px;
426 |                         border-radius: $radius;
427 |                         border: 1px solid #ddd;
428 |                         font-size: 16px;
429 |                         & + .btn-clear {
430 |                             cursor: pointer;
431 |                             padding: 5px;
432 |                             color: #000;
433 |                             display: inline-block;
434 |                             font-size: 14px;
435 |                             &:active {
436 |                                 color: #ccc;
437 |                             }
438 |                             &:hover {
439 |                                 color: #666;
440 |                             }
441 |                         }
442 |                     }
443 |                 }
444 |                 > .tip {
445 |                     height: 24px;
446 |                     padding: 5px;
447 |                     > p {
448 |                         font-size: 14px;
449 |                         &.success {
450 |                             color: #4caf50;
451 |                         }
452 | 
453 |                         &.error {
454 |                             color: #ff5722;
455 |                         }
456 |                     }
457 |                 }
458 |             }
459 | 
460 |             > section.trigger {
461 |                 display: flex;
462 |                 align-items: center;
463 |                 align-content: center;
464 |                 h3 {
465 |                     font-size: 14px;
466 |                 }
467 |                 > label {
468 |                     padding: 0 10px;
469 |                 }
470 |             }
471 |         }
472 |     }
473 | }
474 | </style>
475 | 


--------------------------------------------------------------------------------
/packages/www/src/RULES.js:
--------------------------------------------------------------------------------
  1 | module.exports = [{
  2 |     title: '火车车次',
  3 |     rule: /^[GCDZTSPKXLY1-9]\d{1,4}$/,
  4 |     examples: ['G1868', 'D102', 'D9', 'Z5', 'Z24', 'Z17']
  5 | },
  6 | {
  7 |     title: '手机机身码(IMEI)',
  8 |     rule: /^\d{15,17}$/,
  9 |     examples: ['123456789012345', '1234567890123456', '12345678901234567']
 10 | },
 11 | {
 12 |     title: '必须带端口号的网址(或ip)',
 13 |     rule: /^((ht|f)tps?:\/\/)?[\w-]+(\.[\w-]+)+:\d{1,5}\/?$/,
 14 |     examples: ['https://www.qq.com:8080', '127.0.0.1:5050', 'baidu.com:8001', 'http://192.168.1.1:9090'],
 15 |     counterExamples: ['192.168.1.1', 'https://www.jd.com']
 16 | },
 17 | {
 18 |     // 参考: 
 19 |     // https://baike.baidu.com/item/%E9%A1%B6%E7%BA%A7%E5%9F%9F%E5%90%8D#4_1
 20 |     // https://baike.baidu.com/item/%E9%A1%B6%E7%BA%A7%E5%9F%9F%E5%90%8D#7
 21 |     // 也参考谷歌浏览器的地址栏, 如果输入非字母不会被识别为域名
 22 |     title: '网址(URL)',
 23 |     rule: /^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-]([^!@#$%^&*?.\s]{0,63}[^!@#$%^&*?.\s])?\.)+[a-z]{2,6}\/?/,
 24 |     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'],
 25 |     counterExamples: ['....']
 26 | },
 27 | {
 28 |     title: '统一社会信用代码',
 29 |     rule: /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/,
 30 |     examples: ['91230184MA1BUFLT44', '92371000MA3MXH0E3W'],
 31 | },
 32 | {
 33 |     title: '统一社会信用代码(宽松匹配)(15位/18位/20位数字/字母)',
 34 |     rule: /^(([0-9A-Za-z]{15})|([0-9A-Za-z]{18})|([0-9A-Za-z]{20}))$/,
 35 |     examples: ['91110108772551611J', '911101085923662400']
 36 | },
 37 | {
 38 |     title: '迅雷链接',
 39 |     rule: /^thunderx?:\/\/[a-zA-Z\d]+=$/,
 40 |     examples: ['thunder://QUEsICdtYWduZXQ6P3h0PXVybjpidGloOjBCQTE0RTUxRkUwNjU1RjE0Qzc4NjE4RjY4NDY0QjZFNTEyNjcyOUMnWlo='],
 41 | },
 42 | 
 43 | {
 44 |     title: 'ed2k链接(宽松匹配)',
 45 |     rule: /^ed2k:\/\/\|file\|.+\|\/$/,
 46 |     examples: ['ed2k://|file|%E5%AF%84%E7%94%9F%E8%99%AB.PARASITE.2019.HD-1080p.X264.AAC-UUMp4(ED2000.COM).mp4|2501554832|C0B93E0879C6071CBED732C20CE577A3|h=5HTKZPQFYRKORN52I3M7GQ4QQCIHFIBV|/'],
 47 | },
 48 | 
 49 | {
 50 |     title: '磁力链接(宽松匹配)',
 51 |     rule: /^magnet:\?xt=urn:btih:[0-9a-fA-F]{40,}.*$/,
 52 |     examples: ['magnet:?xt=urn:btih:40A89A6F4FB1498A98087109D012A9A851FBE0FC'],
 53 | },
 54 | {
 55 |     title: '子网掩码(不包含 0.0.0.0)',
 56 |     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)$/,
 57 |     examples: ['255.255.255.0', '255.255.255.255', '255.240.0.0']
 58 | },
 59 | {
 60 |     title: 'linux"隐藏文件"路径',
 61 |     rule: /^\/(?:[^/]+\/)*\.[^/]*/,
 62 |     examples: ['/usr/ad/.dd', '/root/.gitignore', '/.gitignore']
 63 | },
 64 | {
 65 |     title: 'linux文件夹路径',
 66 |     rule: /^\/(?:[^/]+\/)*$/,
 67 |     examples: ['/usr/ad/dd/', '/', '/root/', '/ a a / a / a a /']
 68 | },
 69 | {
 70 |     title: 'linux文件路径',
 71 |     rule: /^\/(?:[^/]+\/)*[^/]+$/,
 72 |     examples: ['/root/b.ts', '/root/abc']
 73 | },
 74 | {
 75 |     title: 'window"文件夹"路径',
 76 |     rule: /^[a-zA-Z]:\\(?:\w+\\?)*$/,
 77 |     examples: ['C:\\Users\\Administrator\\Desktop', 'e:\\m\\']
 78 | },
 79 | {
 80 |     title: 'window下"文件"路径',
 81 |     rule: /^[a-zA-Z]:\\(?:\w+\\)*\w+\.\w+$/,
 82 |     examples: ['C:\\Users\\Administrator\\Desktop\\qq.link', 'e:\\m\\vscode.exe']
 83 | },
 84 | {
 85 |     title: '股票代码(A股)',
 86 |     rule: /^(s[hz]|S[HZ])(000[\d]{3}|002[\d]{3}|300[\d]{3}|600[\d]{3}|60[\d]{4})$/,
 87 |     examples: ['sz000858', 'SZ002136', 'sz300675', 'SH600600', 'sh601155']
 88 | },
 89 | {
 90 |     title: '大于等于0, 小于等于150, 支持小数位出现5, 如145.5, 用于判断考卷分数',
 91 |     rule: /^150$|^(?:\d|[1-9]\d|1[0-4]\d)(?:\.5)?$/,
 92 |     examples: [150, 100.5]
 93 | },
 94 | {
 95 |     title: 'html注释',
 96 |     rule: /<!--[\s\S]*?-->/g,
 97 |     examples: ['<!--<div class="_bubble"></div>--><div>chenguzhen87</div><div class="_bubble"></div>-->']
 98 | },
 99 | {
100 |     title: 'md5格式(32位)',
101 |     rule: /^[a-fA-F0-9]{32}$/,
102 |     examples: ['21fe181c5bfc16306a6828c1f7b762e8'],
103 | },
104 | {
105 |     title: 'GUID/UUID',
106 |     rule: /^[a-f\d]{4}(?:[a-f\d]{4}-){4}[a-f\d]{12}$/i,
107 |     examples: ['e155518c-ca1b-443c-9be9-fe90fdab7345', '41E3DAF5-6E37-4BCC-9F8E-0D9521E2AA8D', '00000000-0000-0000-0000-000000000000'],
108 | },
109 | {
110 |     title: '版本号(version)格式必须为X.Y.Z',
111 |     rule: /^\d+(?:\.\d+){2}$/,
112 |     examples: ['16.3.10']
113 | },
114 | {
115 |     title: '视频(video)链接地址(视频格式可按需增删)',
116 |     rule: /^https?:\/\/(.+\/)+.+(\.(swf|avi|flv|mpg|rm|mov|wav|asf|3gp|mkv|rmvb|mp4))$/i,
117 |     examples: ['http://www.abc.com/video/wc.avi']
118 | },
119 | {
120 |     title: '图片(image)链接地址(图片格式可按需增删)',
121 |     rule: /^https?:\/\/(.+\/)+.+(\.(gif|png|jpg|jpeg|webp|svg|psd|bmp|tif))$/i,
122 |     examples: ['https://www.abc.com/logo.png', 'http://www.abc.com/logo.png']
123 | },
124 | {
125 |     title: '24小时制时间(HH:mm:ss)',
126 |     rule: /^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d$/,
127 |     examples: ['23:34:55']
128 | },
129 | {
130 |     title: '12小时制时间(hh:mm:ss)',
131 |     rule: /^(?:1[0-2]|0?[1-9]):[0-5]\d:[0-5]\d$/,
132 |     examples: ['11:34:55'],
133 |     counterExamples: ['23:34:55']
134 | },
135 | {
136 |     title: 'base64格式',
137 |     rule: /^\s*data:(?:[a-z]+\/[a-z0-9-+.]+(?:;[a-z-]+=[a-z0-9-]+)?)?(?:;base64)?,([a-z0-9!
amp;',()*+;=\-._~:@/?%\s]*?)\s*$/i,
138 |     examples: ['data:image/gif;base64,xxxx==']
139 | },
140 | {
141 |     title: '数字/货币金额(支持负数、千分位分隔符)',
142 |     rule: /^-?\d{1,3}(,\d{3})*(\.\d{1,2})?$/ ,
143 |     examples: [100, -0.99, 3, 234.32, -1, 900, 235.09, '12,345,678.90']
144 | },
145 | {
146 |     title: '银行卡号(10到30位, 覆盖对公/私账户, 参考[微信支付](https://pay.weixin.qq.com/wiki/doc/api/xiaowei.php?chapter=22_1))',
147 |     rule: /^[1-9]\d{9,29}$/,
148 |     examples: [6234567890, 6222026006705354217]
149 | },
150 | {
151 |     title: '中文姓名',
152 |     rule: /^(?:[\u4e00-\u9fa5·]{2,16})$/,
153 |     examples: ['葛二蛋', '凯文·杜兰特', '德克·维尔纳·诺维茨基']
154 | },
155 | {
156 |     title: '英文姓名',
157 |     rule: /(^[a-zA-Z][a-zA-Z\s]{0,20}[a-zA-Z]$)/,
158 |     examples: ['James', 'Kevin Wayne Durant', 'Dirk Nowitzki']
159 | },
160 | {
161 |     title: '车牌号(新能源)',
162 |     rule: /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z](([DF]((?![IO])[a-zA-Z0-9](?![IO]))[0-9]{4})|([0-9]{5}[DF]))$/,
163 |     examples: ['京AD92035', '甘G23459F', '京A19203D'],
164 | },
165 | {
166 |     title: '车牌号(非新能源)',
167 |     rule: /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]$/,
168 |     examples: ['京A00599', '黑D23908']
169 | },
170 | {
171 |     title: '车牌号(新能源+非新能源)',
172 |     rule: /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$/,
173 |     examples: ['京A12345D', '京A00599', '京AD92035', '甘G23459F', '京AA92035'],
174 |     counterExamples: ['宁AD1234555555', '浙苏H6F681']
175 | },
176 | {
177 |     title: '手机号(mobile phone)中国(严谨), 根据工信部最新公布的手机号段',
178 |     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}$/,
179 |     examples: ['008618311006933', '+8617888829981', '19119255642', '19519255642']
180 | },
181 | {
182 |     title: '手机号(mobile phone)中国(宽松), 只要是13,14,15,16,17,18,19开头即可',
183 |     rule: /^(?:(?:\+|00)86)?1[3-9]\d{9}$/,
184 |     examples: ['008618311006933', '+8617888829981', '19119255642']
185 | },
186 | {
187 |     title: '手机号(mobile phone)中国(最宽松), 只要是1开头即可, 如果你的手机号是用来接收短信, 优先建议选择这一条',
188 |     rule: /^(?:(?:\+|00)86)?1\d{10}$/,
189 |     examples: ['008618311006933', '+8617888829981', '19119255642']
190 | },
191 | {
192 |     title: '日期(宽松)',
193 |     rule: /^\d{1,4}(-)(1[0-2]|0?[1-9])\1(0?[1-9]|[1-2]\d|30|31)$/,
194 |     examples: ['1990-12-12', '1-1-1', '0000-1-1'],
195 |     counterExamples: ['2020-00-01']
196 | },
197 | 
198 | {
199 |     title: '日期(严谨, 支持闰年判断)',
200 |     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)$/,
201 |     examples: ['1990-12-12', '2000-02-29'],
202 |     counterExamples: ['2021-02-29']
203 | },
204 | 
205 | {
206 |     title: '中国省',
207 |     rule: /^浙江|上海|北京|天津|重庆|黑龙江|吉林|辽宁|内蒙古|河北|新疆|甘肃|青海|陕西|宁夏|河南|山东|山西|安徽|湖北|湖南|江苏|四川|贵州|云南|广西|西藏|江西|广东|福建|台湾|海南|香港|澳门$/,
208 |     examples: ['浙江', '台湾'],
209 |     counterExamples: ['哈尔滨']
210 | },
211 | 
212 | {
213 |     title: '可以被moment转化成功的时间 YYYYMMDD HH:mm:ss',
214 |     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$/,
215 |     examples: ['2020/01/01 23:59:59', '2020-01-01 00:00:00', '20200101 11:11:11'],
216 |     counterExamples: ['2020/00/01 23:59:59', '2020-01/01 23:59:59', '2020-01-01 23:59:61', '2020-01-0100:00:00',]
217 | },
218 | {
219 |     title: 'email(邮箱)',
220 |     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,}))$/,
221 |     examples: ['90203918@qq.com', 'nbilly@126.com', '汉字@qq.com']
222 | },
223 | 
224 | {
225 |     title: '座机(tel phone)电话(国内),如: 0341-86091234',
226 |     rule: /^(?:(?:\d{3}-)?\d{8}|^(?:\d{4}-)?\d{7,8})(?:-\d+)?$/,
227 |     examples: ['0936-4211235', '89076543', '010-12345678-1234']
228 | },
229 | 
230 | {
231 |     title: '身份证号(1代,15位数字)',
232 |     rule: /^[1-9]\d{7}(?:0\d|10|11|12)(?:0[1-9]|[1-2][\d]|30|31)\d{3}$/,
233 |     examples: ['123456991010193']
234 | },
235 | {
236 |     title: '身份证号(2代,18位数字),最后一位是校验位,可能为数字或字符X',
237 |     rule: /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/,
238 |     examples: ['12345619991205131x']
239 | },
240 | {
241 |     title: '身份证号, 支持1/2代(15位/18位数字)',
242 |     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)$/,
243 |     examples: ['622223199912051311', '12345619991205131x', '123456991010193']
244 | },
245 | {
246 |     title: '护照(包含香港、澳门)',
247 |     rule: /(^[EeKkGgDdSsPpHh]\d{8}$)|(^(([Ee][a-fA-F])|([DdSsPp][Ee])|([Kk][Jj])|([Mm][Aa])|(1[45]))\d{7}$)/,
248 |     examples: ['s28233515', '141234567', '159203084', 'MA1234567', 'K25345719']
249 | },
250 | {
251 |     title: '帐号是否合法(字母开头,允许5-16字节,允许字母数字下划线组合',
252 |     rule: /^[a-zA-Z]\w{4,15}$/,
253 |     examples: ['justin', 'justin1989', 'justin_666']
254 | },
255 | {
256 |     title: '中文/汉字',
257 |     // rule: /^[\u4E00-\u9FA5]+$/,
258 |     rule: /^(?:[\u3400-\u4DB5\u4E00-\u9FEA\uFA0E\uFA0F\uFA11\uFA13\uFA14\uFA1F\uFA21\uFA23\uFA24\uFA27-\uFA29]|[\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0])+$/,
259 |     examples: ['正则', '前端']
260 | },
261 | {
262 |     title: '小数(支持科学计数)',
263 |     rule: /^[+-]?(\d+([.]\d*)?([eE][+-]?\d+)?|[.]\d+([eE][+-]?\d+)?)$/,
264 |     examples: ['0.0', '0.09','4E+4']
265 | },
266 | {
267 |     title: '只包含数字',
268 |     rule: /^\d+$/,
269 |     examples: [12345678]
270 | },
271 | {
272 |     title: 'html标签(宽松匹配)',
273 |     rule: /<(\w+)[^>]*>(.*?<\/\1>)?/,
274 |     examples: ['<div id="app"> 2333 </div>', '<input type="text">', '<br>']
275 | },
276 | 
277 | {
278 |     title: '匹配中文汉字和中文标点',
279 |     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]/,
280 |     examples: ["匹配中文汉字以及中文标点符号 。 ? ! , 、 ; : “ ” ‘ ' ( ) 《 》 〈 〉 【 】 『 』 「 」 ﹃ ﹄ 〔 〕 … — ~ ﹏ ¥"]
281 | },
282 | 
283 | {
284 |     title: 'qq号格式正确',
285 |     rule: /^[1-9][0-9]{4,10}$/,
286 |     examples: [903013545, 9020304]
287 | },
288 | {
289 |     title: '数字和字母组成',
290 |     rule: /^[A-Za-z0-9]+$/,
291 |     examples: ['james666', 'haha233hi']
292 | },
293 | {
294 |     title: '英文字母',
295 |     rule: /^[a-zA-Z]+$/,
296 |     examples: ['Russel']
297 | },
298 | {
299 |     title: '小写英文字母组成',
300 |     rule: /^[a-z]+$/,
301 |     examples: ['russel']
302 | },
303 | {
304 |     title: '大写英文字母',
305 |     rule: /^[A-Z]+$/,
306 |     examples: ['ABC', 'KD']
307 | },
308 | {
309 |     title: '密码强度校验,最少6位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符',
310 |     rule: /^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])(?=\S*[!@#$%^&*? ])\S*$/,
311 |     examples: ['Kd@curry666']
312 | },
313 | {
314 |     title: '用户名校验,4到16位(字母,数字,下划线,减号)',
315 |     rule: /^[\w-]{4,16}$/,
316 |     examples: ['xiaohua_qq']
317 | },
318 | {
319 |     title: 'ip-v4[:端口]',
320 |     rule: /^((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(?::(?:[0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$/,
321 |     examples: ['172.16.0.0', '172.16.0.0:8080', '127.0.0.0', '127.0.0.0:998']
322 | },
323 | {
324 |     title: 'ip-v6[:端口]',
325 |     rule: /(^(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$)|(^\[(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))\](?::(?:[0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$)/i,
326 |     examples: ['2031:0000:130f:0000:0000:09c0:876a:130b', '[2031:0000:130f:0000:0000:09c0:876a:130b]:8080']
327 | },
328 | {
329 |     title: '16进制颜色',
330 |     rule: /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3}|[a-fA-F0-9]{8}|[a-fA-F0-9]{4})$/,
331 |     examples: ['#f00', '#F90', '#000', '#fe9de8', '#f8f8f8ff', '#f003']
332 | },
333 | {
334 |     title: '微信号(wx),6至20位,以字母开头,字母,数字,减号,下划线',
335 |     rule: /^[a-zA-Z][-_a-zA-Z0-9]{5,19}$/,
336 |     examples: ['github666', 'kd_-666']
337 | },
338 | {
339 |     title: '邮政编码(中国)',
340 |     rule: /^(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}$/,
341 |     examples: ['734500', '100101']
342 | },
343 | {
344 |     title: '中文和数字',
345 |     rule: /^((?:[\u3400-\u4DB5\u4E00-\u9FEA\uFA0E\uFA0F\uFA11\uFA13\uFA14\uFA1F\uFA21\uFA23\uFA24\uFA27-\uFA29]|[\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0])|(\d))+$/,
346 |     examples: ['哈哈哈', '你好6啊']
347 | },
348 | {
349 |     title: '不能包含字母',
350 |     rule: /^[^A-Za-z]*$/,
351 |     examples: ['你好6啊', '@¥()!']
352 | },
353 | {
354 |     title: 'java包名',
355 |     rule: /^([a-zA-Z_]\w*)+([.][a-zA-Z_]\w*)+$/,
356 |     examples: ['com.bbb.name']
357 | },
358 | {
359 |     title: 'mac地址',
360 |     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,
361 |     examples: ['38:f9:d3:4b:f5:51', '00-0C-29-CA-E4-66']
362 | },
363 | {
364 |     title: '匹配连续重复的字符',
365 |     rule: /(.)\1+/,
366 |     examples: ['我我我', '112233', '11234']
367 | },
368 | {
369 |     title: '数字和英文字母组成,并且同时含有数字和英文字母',
370 |     rule: /^(?=.*[a-zA-Z])(?=.*\d).+$/,
371 |     examples: ['我a我1我', 'a对1']
372 | },
373 | {
374 |     title: '香港身份证 ',
375 |     rule: /^[a-zA-Z]\d{6}\([\dA]\)$/,
376 |     examples: ['K034169(1)']
377 | },
378 | {
379 |     // 参考: 
380 |     // 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
381 |     title: '澳门身份证 ',
382 |     rule: /^[1|5|7]\d{6}\(\d\)$/,
383 |     examples: ['5686611(1)']
384 | },
385 | {
386 |     title: '台湾身份证 ',
387 |     rule: /^[a-zA-Z][0-9]{9}$/,
388 |     examples: ['U193683453']
389 | },
390 | {
391 |     title: '大写字母,小写字母,数字,特殊符号 `@#$%^&*`~()-+=` 中任意3项密码',
392 |     rule: /^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_!@#$%^&*`~()-+=]+$)(?![a-z0-9]+$)(?![a-z\W_!@#$%^&*`~()-+=]+$)(?![0-9\W_!@#$%^&*`~()-+=]+$)[a-zA-Z0-9\W_!@#$%^&*`~()-+=]/,
393 |     examples: ['a1@', 'A1@', 'Aa@']
394 | },
395 | {
396 |     title: 'ASCII码表中的全部的特殊字符',
397 |     rule: /[\x21-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E]+/,
398 |     examples: ["[", ".", "^", "&3%"]
399 | },
400 | {
401 |     title: '正整数,不包含0',
402 |     rule: /^\+?[1-9]\d*$/,
403 |     examples: [1231]
404 | },
405 | {
406 |     title: '负整数,不包含0',
407 |     rule: /^-[1-9]\d*$/,
408 |     examples: [-1231]
409 | },
410 | {
411 |     title: '整数',
412 |     rule: /^(?:0|(?:-?[1-9]\d*))$/,
413 |     examples: [-1231, 123, 0],
414 |     counterExamples: ['01']
415 | },
416 | {
417 |     title: '浮点数',
418 |     rule: /^(-?[1-9]\d*\.\d+|-?0\.\d*[1-9]\d*|0\.0+)$/,
419 |     examples: ["1.23", "-1.01", "0.00"]
420 |     // allow "1.23", allow "-0.1", allow "0.00", ban "-0.00", ban "2.", allow "2.0"
421 | },
422 | {
423 |     title: '浮点数(严格)',
424 |     rule: /^(-?[1-9]\d*\.\d+|-?0\.\d*[1-9])$/,
425 |     examples: ["1.23", "-1.01"]
426 |     // allow "1.23", allow "-0.1", ban "2.", ban "2.0"
427 | },
428 | {
429 |     title: 'email(支持中文邮箱)',
430 |     rule: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
431 |     examples: ['90203918@qq.com', 'nbilly@126.com', '啦啦啦@126.com']
432 | },
433 | 
434 | {
435 |     title: '域名(非网址, 不包含协议)',
436 |     rule: /^([0-9a-zA-Z-]{1,}\.)+([a-zA-Z]{2,})$/,
437 |     examples: ['www.baidu.com',
438 |         'baidu.com',
439 |         'baidu.com.cn',
440 |         'api.baidu.com',
441 |         'nodejs.org',
442 |         'nodejs.cn'],
443 |     counterExamples: ['http://baidu.com', 'https://baidu.com', 'www.百度.com']
444 | },
445 | 
446 | {
447 |     title: '军官/士兵证',
448 |     rule: /^[\u4E00-\u9FA5](字第)([0-9a-zA-Z]{4,8})(号?)$/,
449 |     examples: ['军字第2001988号', '士字第P011816X号'],
450 | },
451 | {
452 |     title: '户口薄',
453 |     rule: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
454 |     examples: ['441421999707223115'],
455 | },
456 | 
457 | ];
458 | 


--------------------------------------------------------------------------------
/packages/www/src/main.js:
--------------------------------------------------------------------------------
 1 | import Vue from 'vue'
 2 | import App from './App.vue'
 3 | 
 4 | Vue.config.productionTip = false
 5 | 
 6 | if ('serviceWorker' in navigator) {
 7 |     window.addEventListener('load', function() {
 8 |         navigator.serviceWorker.register('./sw.js');
 9 |     });
10 | }
11 | 
12 | new Vue({
13 |     render: h => h(App),
14 | }).$mount('#app')


--------------------------------------------------------------------------------
/packages/www/vue.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 |   // publicPath: process.env.NODE_ENV === 'production'
3 |   // ? '/any-rule/'
4 |   // : '/'
5 | }


--------------------------------------------------------------------------------
/scripts/genCommond.js:
--------------------------------------------------------------------------------
 1 | const RULES = require('../packages/www/src/RULES.js');
 2 | const pkg = require('../package.json');
 3 | const fs = require('fs');
 4 | const chalk = require('chalk');
 5 | 
 6 | pkg.activationEvents = ['*'];
 7 | pkg.contributes.commands = RULES.map((rule, index) => ({
 8 |     command: 'extension.rule' + index,
 9 |     title: `$(rocket) zz: ${rule.title}`
10 | }));
11 | 
12 | pkg.contributes.commands.push({
13 |     command: 'extension.rule.callByMenu',
14 |     title: `🦕正则大全(${RULES.length}条)`
15 | });
16 | 
17 | // console.log(JSON.stringify(pkg));
18 | fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 4), 'utf8');
19 | console.log(chalk.green('🚀 pkg文件修改完毕, 请等待生成vsc包...'));


--------------------------------------------------------------------------------
/scripts/md.js:
--------------------------------------------------------------------------------
  1 | const fs = require('fs');
  2 | const chalk = require('chalk');
  3 | const json = require('../packages/www/src/RULES');
  4 | const VSC_URL = 'https://marketplace.visualstudio.com/items?itemName=russell.any-rule'
  5 | const badges = [
  6 |     // `![](https://img.shields.io/badge/状态-积极更新-673ab7.svg)`,
  7 | 
  8 |     `![已收录${json.length}条](https://img.shields.io/badge/已收录-${json.length}条-673ab7.svg)`,
  9 | 
 10 |     
 11 |     `[![版本](https://badgen.net/vs-marketplace/v/russell.any-rule)](https://marketplace.visualstudio.com/items?itemName=russell.any-rule)`,
 12 | 
 13 |     `[![安装量](https://badgen.net/vs-marketplace/i/russell.any-rule)](https://marketplace.visualstudio.com/items?itemName=russell.any-rule)`,
 14 | 
 15 |     `[![下载量](https://badgen.net/vs-marketplace/d/russell.any-rule)](https://marketplace.visualstudio.com/items?itemName=russell.any-rule)`,
 16 | 
 17 |     `![MIT](https://img.shields.io/badge/license-MIT-F44336.svg)`,
 18 | 
 19 |     `[![CircleCI](https://badgen.net/github/status/any86/any-rule/master/ci/circleci)](https://circleci.com/gh/any86/any-rule)`
 20 | 
 21 |     // vscode上传不让用svg
 22 |     // `[![Node CI](https://github.com/any86/any-rule/workflows/Node%20CI/badge.svg)](https://github.com/any86/any-rule/actions)`
 23 | ];
 24 | 
 25 | let content = `# 正则大全  ${badges.join(' ')}
 26 | 
 27 | 🦕支持**web** / **vscode** / **idea** / **Alfred Workflow**多平台
 28 | 
 29 | ## :rocket:web版本
 30 | https://any-rule.vercel.app/
 31 | 
 32 | ## 🍭vscode插件
 33 | 
 34 | ### 安装
 35 | vscode应用商店中搜索"**any-rule**".
 36 | 
 37 | ### 使用
 38 | **方式1:**
 39 | 
 40 | 1. 按**F1**(mac下fn+F1)打开正则列表.
 41 | 2. **输入关键词搜索**, 比如"手机".
 42 | 
 43 | ![GIF](https://user-images.githubusercontent.com/8264787/146724787-888a8666-5d2a-4e5e-b383-aec7c53bd312.gif)
 44 | 
 45 | **方式2:**
 46 | 
 47 | 右键选择"🦕正则大全".
 48 | 
 49 | ![GIF](https://user-images.githubusercontent.com/8264787/146725447-4d92caed-2dd0-4f11-91d1-8da9cd8ff08b.gif)
 50 | 
 51 | **方式3:**
 52 | 
 53 | 在代码任意位置输入"**@zz**".
 54 | 
 55 | ![GIF](https://user-images.githubusercontent.com/8264787/146725402-30b34119-b709-4d49-adb2-af8dbb786d3b.gif)
 56 | 
 57 | ## 👩‍🏫图解正则
 58 | <details>
 59 | <summary>查看详情</summary>
 60 | 每次在any-rule中选择正则后会弹出提示, 可点击"🤖图解正则".
 61 | 
 62 | ![image](https://user-images.githubusercontent.com/8264787/146726200-d97e48c3-df76-4531-8210-b6935fffb997.png)
 63 | 
 64 | 点击后可以看到正则解析, 方便大家学习.
 65 | 
 66 | ![image](https://user-images.githubusercontent.com/8264787/146726350-58166bf9-7f7f-4685-86aa-f055d0c0b914.png)
 67 | 
 68 | **注意**: 图解直接使用了https://regexper.com, 在此对作者表示敬意和感谢.
 69 | </details>
 70 | 
 71 | ## 社区版本
 72 | 
 73 | 社区版本非本人维护, 只是其他开发者使用了any-rule整理的正则内容, 如使用出现问题可直接与其开发者联系.
 74 | 
 75 | [idea版](https://github.com/zhoriya/idea-rule)
 76 | 
 77 | [Alfred Workflow版](https://github.com/cccyb/workflows)
 78 | 
 79 | [hyjs: 函数封装版](https://github.com/heiyehk/hyjs/tree/main/packages/utils)
 80 | 
 81 | [命令行版本](https://github.com/shenguanjiejie/workwork)
 82 | 
 83 | [uTools版本](https://github.com/trentlee0/utools-any-rule)
 84 | 
 85 | ## :fire:关于PR
 86 | 欢迎大家PR, 步骤如下:
 87 | 1. **正则**请在**packages/www/src/RULES.js**中添加.
 88 | 2. 运行\`npm run test:rules\`进行测试.
 89 | 3. 运行\`npm run build:md\`更新**README.md**.
 90 | 4. 请务必提交到**develop**分支.
 91 | 
 92 | 在此感谢大家对**any-rule**做出的贡献! 
 93 | 
 94 | ## 🍔正则
 95 | `;
 96 | 
 97 | json.forEach(({title, rule})=>{
 98 |     content+= `\r\n### ${title}\r\n`;
 99 |     content+= `\`\`\`javascript\r\n`;
100 |     content+= `${rule}\r\n\`\`\`\r\n`;
101 | });
102 | fs.writeFileSync('./README.md',content,'utf-8');
103 | console.log(chalk.green('生成完毕'));
104 | 


--------------------------------------------------------------------------------
/src/extension.ts:
--------------------------------------------------------------------------------
 1 | // The module 'vscode' contains the VS Code extensibility API
 2 | // Import the module and reference it with the alias vscode in your code below
 3 | import {
 4 | 	ExtensionContext
 5 | } from 'vscode';
 6 | const RULES: { title: string, rule: RegExp, examples: string[] }[] = require('../packages/www/src/RULES.js');
 7 | import useCommand from './useCommand';
 8 | import useQuickPick from './useQuickPick';
 9 | import useMenuCommand from './useMenuCommand';
10 | 
11 | export function activate(context: ExtensionContext) {
12 | 	useCommand(context, RULES);
13 | 	useQuickPick(context, RULES);
14 | 	useMenuCommand(context, RULES);
15 | }
16 | 
17 | export function deactivate() { }
18 | 


--------------------------------------------------------------------------------
/src/insertLog.ts:
--------------------------------------------------------------------------------
 1 | import axios from 'axios';
 2 | import {version ,env} from 'vscode';
 3 | import {getCodeLanguage,getExtensionVersion} from './shared';
 4 | const http = axios.create({
 5 |     baseURL: 'https://leancloud.cn:443/1.1/classes/',
 6 |     timeout: 1000,
 7 |     headers: {
 8 |         "X-LC-Id": "BKaqtaJScQuqKtkAyl5jeloo-gzGzoHsz",
 9 |         "X-LC-Key": "y41qiVPTwnzLIgbDcEzcwHit",
10 |         "Content-Type": "application/json"
11 |     }
12 | });
13 | /**
14 |  * 插入日志
15 |  */
16 | export default function ({ rule, title, method }: { rule: string, title: string, method: string }) {
17 |     const {language,machineId} = env;
18 |     http.post('https://leancloud.cn:443/1.1/classes/Log', {
19 |         vscodeVersion: version,
20 |         codeLanguage: getCodeLanguage(),
21 |         language,
22 |         machineId,
23 |         rule,
24 |         title,
25 |         extensionVersion:getExtensionVersion(),
26 |         method
27 |     });
28 | };


--------------------------------------------------------------------------------
/src/interface.d.ts:
--------------------------------------------------------------------------------
 1 | export interface IRule {
 2 |     title: string;
 3 |     keywords?: string[];
 4 |     regex?: RegExp | string;
 5 |     rules?: IRule[];
 6 |     examples?: string[];
 7 | }
 8 | 
 9 | export interface Rule{
10 |     title:string,
11 |     rule:RegExp,
12 |     examples:string[]
13 | }


--------------------------------------------------------------------------------
/src/shared.ts:
--------------------------------------------------------------------------------
 1 | import { extensions, window} from 'vscode';
 2 | 
 3 | /**
 4 |  * 获取编程语言
 5 |  */
 6 | export function getCodeLanguage():string{
 7 |     return window.activeTextEditor ? window.activeTextEditor.document.languageId as string : '';
 8 | };
 9 | 
10 | /**
11 |  * 获取插件版本号
12 |  */
13 | export function getExtensionVersion():string|void {
14 |     const e = extensions.getExtension('russell.any-rule');
15 |     return e && e.packageJSON.version;
16 | }


--------------------------------------------------------------------------------
/src/showResultMessage.ts:
--------------------------------------------------------------------------------
 1 | import { extensions, window, version, env, Uri, languages } from 'vscode';
 2 | import { getCodeLanguage, getExtensionVersion } from './shared'
 3 | import insertLog from './insertLog';
 4 | 
 5 | const BUTTON_FEEDBACK = '✋意见反馈';
 6 | const BUTTON_DIAGRAMMATIZE = '👩‍🏫图解正则';
 7 | const BUTTON_CANCEL = '关闭';
 8 | 
 9 | export default function (title: string, rule: string): void {
10 |     // window.setStatusBarMessage(`已插入正则: "${title}", 点击查看更多🔥`)
11 |     window.showInformationMessage(`已插入正则: "${title}"`, BUTTON_DIAGRAMMATIZE, BUTTON_FEEDBACK, BUTTON_CANCEL).then(value => {
12 |         if (BUTTON_FEEDBACK === value) {
13 |             insertLog({
14 |                 rule,
15 |                 title,
16 |                 method: BUTTON_FEEDBACK
17 |             });
18 |             const URL = Uri.parse(genGithubIssueURL(title));
19 |             env.openExternal(URL);
20 |         } else if (BUTTON_DIAGRAMMATIZE === value) {
21 |             insertLog({
22 |                 rule,
23 |                 title,
24 |                 method: BUTTON_DIAGRAMMATIZE
25 |             });
26 |             const URL = Uri.parse(`https://regexper.com/#${rule}`);
27 |             env.openExternal(URL);
28 |         }
29 |     });
30 | }
31 | // gihub issue模板
32 | function genGithubIssueURL(title: string): string {
33 |     const BASE_URL = 'https://github.com/any86/any-rule/issues/new';
34 |     const TITLE = `title=[vscode feedback] ${title}`;
35 |     //     const BODY = `body=### vscode version
36 |     // ${version}    
37 |     // ### extension version
38 |     // ${getExtensionVersion()}
39 |     // ### code language
40 |     // ${getCodeLanguage()}
41 |     // ### comment
42 |     // 请留言...
43 |     // `;
44 |     return BASE_URL + '?' + TITLE;
45 | }
46 | 


--------------------------------------------------------------------------------
/src/test/runTest.ts:
--------------------------------------------------------------------------------
 1 | import * as path from 'path';
 2 | 
 3 | import { runTests } from 'vscode-test';
 4 | 
 5 | async function main() {
 6 | 	try {
 7 | 		// The folder containing the Extension Manifest package.json
 8 | 		// Passed to `--extensionDevelopmentPath`
 9 | 		const extensionDevelopmentPath = path.resolve(__dirname, '../../');
10 | 
11 | 		// The path to test runner
12 | 		// Passed to --extensionTestsPath
13 | 		const extensionTestsPath = path.resolve(__dirname, './suite/index');
14 | 
15 | 		// Download VS Code, unzip it and run the integration test
16 | 		await runTests({ extensionDevelopmentPath, extensionTestsPath });
17 | 	} catch (err) {
18 | 		console.error('Failed to run tests');
19 | 		process.exit(1);
20 | 	}
21 | }
22 | 
23 | main();
24 | 


--------------------------------------------------------------------------------
/src/test/suite/extension.test.ts:
--------------------------------------------------------------------------------
 1 | import * as assert from 'assert';
 2 | import { before } from 'mocha';
 3 | 
 4 | // You can import and use all API from the 'vscode' module
 5 | // as well as import your extension to test it
 6 | import * as vscode from 'vscode';
 7 | // import * as myExtension from '../extension';
 8 | 
 9 | suite('Extension Test Suite', () => {
10 | 	before(() => {
11 | 		vscode.window.showInformationMessage('Start all tests.');
12 | 	});
13 | 
14 | 	test('Sample test', () => {
15 | 		assert.equal(-1, [1, 2, 3].indexOf(5));
16 | 		assert.equal(-1, [1, 2, 3].indexOf(0));
17 | 	});
18 | });
19 | 


--------------------------------------------------------------------------------
/src/test/suite/index.ts:
--------------------------------------------------------------------------------
 1 | import * as path from 'path';
 2 | import * as Mocha from 'mocha';
 3 | import * as glob from 'glob';
 4 | 
 5 | export function run(): Promise<void> {
 6 | 	// Create the mocha test
 7 | 	const mocha = new Mocha({
 8 | 		ui: 'tdd',
 9 | 	});
10 | 	mocha.useColors(true);
11 | 
12 | 	const testsRoot = path.resolve(__dirname, '..');
13 | 
14 | 	return new Promise((c, e) => {
15 | 		glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
16 | 			if (err) {
17 | 				return e(err);
18 | 			}
19 | 
20 | 			// Add files to the test suite
21 | 			files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
22 | 
23 | 			try {
24 | 				// Run the mocha test
25 | 				mocha.run(failures => {
26 | 					if (failures > 0) {
27 | 						e(new Error(`${failures} tests failed.`));
28 | 					} else {
29 | 						c();
30 | 					}
31 | 				});
32 | 			} catch (err) {
33 | 				e(err);
34 | 			}
35 | 		});
36 | 	});
37 | }
38 | 


--------------------------------------------------------------------------------
/src/useCommand.ts:
--------------------------------------------------------------------------------
 1 | import { window, commands, Range, ExtensionContext } from "vscode";
 2 | import { Rule } from './interface';
 3 | import insertLog from './insertLog';
 4 | import showResultMessage from './showResultMessage';
 5 | 
 6 | export default function (context: ExtensionContext, RULES: Rule[]) {
 7 |     RULES.forEach(({ title, rule }, index) => {
 8 |         const ruleString = String(rule);
 9 |         const disposable = commands.registerCommand(`extension.rule${index}`, () => {
10 |             const editor = window.activeTextEditor;
11 |             if (editor) {
12 |                 const { selections } = editor;
13 | 
14 |                 editor.edit(editBuilder => {
15 |                     selections.forEach(selection => {
16 |                         const { start, end } = selection;
17 |                         const range = new Range(start, end);
18 |                         editBuilder.replace(range, ruleString);
19 |                     });
20 |                 });
21 | 
22 |                 // 日志
23 |                 insertLog({
24 |                     rule: ruleString,
25 |                     title,
26 |                     method: 'Command'
27 |                 });
28 | 
29 |                 showResultMessage(title, ruleString);
30 |             } else {
31 |                 window.showWarningMessage('any-rule: 只有在编辑文本的时候才可以使用!');
32 |             }
33 |         });
34 |         context.subscriptions.push(disposable);
35 |     });
36 | }


--------------------------------------------------------------------------------
/src/useMenuCommand.ts:
--------------------------------------------------------------------------------
 1 | import { window, commands, Range, ExtensionContext } from "vscode";
 2 | import { Rule } from './interface';
 3 | import insertLog from './insertLog';
 4 | import showResultMessage from './showResultMessage';
 5 | 
 6 | export default function (context: ExtensionContext, RULES: Rule[]) {
 7 | 
 8 |     const disposable = commands.registerCommand(`extension.rule.callByMenu`, () => {
 9 |         // showQuickPick
10 |         window.showQuickPick(RULES.map(({ examples, title, rule }) => {
11 |             // const match = title.match(/\((.+)\)/);
12 |             return {
13 |                 label: title,
14 |                 // description: null !== match ? match[1] : '',
15 |                 rule: String(rule), // 非标准字段, 仅仅为了传值
16 |                 detail: `例如: ${examples.join(' 或 ')}`
17 |             };
18 |         }), {
19 |             placeHolder: '请输入关键词',
20 |             // onDidSelectItem(item){
21 |             // console.log(item)
22 |             // }
23 |         }).then(item => {
24 |             if (!item) return
25 | 
26 |             const editor = window.activeTextEditor;
27 |             if (editor) {
28 |                 const ruleString = String(item.rule);
29 |                 const title = item.label;
30 |                 const { selections } = editor;
31 | 
32 |                 editor.edit(editBuilder => {
33 |                     selections.forEach(selection => {
34 |                         const { start, end } = selection;
35 |                         const range = new Range(start, end);
36 |                         editBuilder.replace(range, ruleString);
37 |                     });
38 |                 });
39 | 
40 |                 // 日志
41 |                 insertLog({
42 |                     rule: ruleString,
43 |                     title,
44 |                     method: 'Menu'
45 |                 });
46 | 
47 |                 showResultMessage(title, ruleString);
48 |             }
49 | 
50 |         });
51 | 
52 | 
53 |     });
54 |     context.subscriptions.push(disposable);
55 | }


--------------------------------------------------------------------------------
/src/useQuickPick.ts:
--------------------------------------------------------------------------------
  1 | import { ExtensionContext, workspace, languages, window, TextDocument, Position, Range, Selection } from "vscode";
  2 | import { Rule } from './interface';
  3 | // import { slugify } from 'transliteration';
  4 | import insertLog from './insertLog';
  5 | import showResultMessage from './showResultMessage';
  6 | 
  7 | export default function (context: ExtensionContext, RULES: Rule[]) {
  8 |     // commands.registerCommand('functions.insertRegex', insertRule);
  9 |     // 不确定是不是都兼容"*", 保守    
 10 |     let { supportedLanguages, triggerStringEnd } = getConfig();
 11 |     workspace.onDidChangeConfiguration(() => {
 12 |         const config = getConfig();
 13 |         supportedLanguages = config.supportedLanguages;
 14 |         triggerStringEnd = config.triggerStringEnd;
 15 |     });
 16 | 
 17 |     const disposable = languages.registerCompletionItemProvider(supportedLanguages.split(','), {
 18 |         provideCompletionItems(document, position) {
 19 |             const { triggerString } = getConfig();
 20 |             // 如果为空表示关闭
 21 |             if (!triggerString) return [];
 22 | 
 23 |             const linePrefix = document.lineAt(position).text.substr(0, position.character);
 24 |             if (!linePrefix.endsWith(triggerString)) return [];
 25 | 
 26 |             // 滞后执行
 27 |             setTimeout(() => {
 28 |                 // showQuickPick
 29 |                 window.showQuickPick(RULES.map(({ examples, title, rule }) => {
 30 |                     // const match = title.match(/\((.+)\)/);
 31 |                     return {
 32 |                         label: title,
 33 |                         // description: null !== match ? match[1] : '',
 34 |                         rule: String(rule), // 非标准字段, 仅仅为了传值
 35 |                         detail: `例如: ${examples.join(' 或 ')}`
 36 |                     };
 37 |                 }), {
 38 |                     placeHolder: '请输入关键词',
 39 |                     // onDidSelectItem(item){
 40 |                     // console.log(item)
 41 |                     // }
 42 |                 }).then(item => {
 43 |                     if (!item) return
 44 |                     insertRule(document, position, item.rule);
 45 | 
 46 |                     // 日志
 47 |                     insertLog({
 48 |                         rule: item.rule,
 49 |                         title: item.label,
 50 |                         method: 'QuickPick'
 51 |                     });
 52 |                     showResultMessage(item.label, item.rule);
 53 |                 });
 54 |             }, 10)
 55 |             return [];
 56 |         },
 57 | 
 58 |         resolveCompletionItem(item) {
 59 |             return item;
 60 |         }
 61 |     }, triggerStringEnd);
 62 |     context.subscriptions.push(disposable);
 63 | }
 64 | 
 65 | 
 66 | function insertRule(document: TextDocument, position: Position, ruleString: string) {
 67 |     const { triggerString } = getConfig();
 68 | 
 69 |     const editor = window.activeTextEditor;
 70 |     if (void 0 === editor) return;
 71 |     editor.edit(editBuilder => {
 72 |         const line = document.lineAt(position);
 73 | 
 74 |         // 起始, "zz."前面的位置
 75 |         const startPostion = position.translate(0, -triggerString.length);
 76 | 
 77 |         editBuilder.replace(new Range(startPostion, position), ruleString);
 78 | 
 79 |         setTimeout(() => {
 80 |             // 全选正则字符串
 81 |             const endPostion = new Position(line.lineNumber, startPostion.character + ruleString.length);
 82 |             editor.selection = new Selection(startPostion, endPostion);
 83 |         }, 0);
 84 |     });
 85 | }
 86 | 
 87 | // 获取配置
 88 | function getConfig() {
 89 |     const configuration = workspace.getConfiguration();
 90 |     const { triggerString, supportedLanguages } = configuration['any-rule'];
 91 |     const { length } = triggerString;
 92 |     const triggerStringStart = triggerString.substr(0, length - 1);
 93 |     const triggerStringEnd = triggerString.substr(-1);
 94 |     console.log(supportedLanguages);
 95 |     return {
 96 |         triggerStringStart,
 97 |         triggerStringEnd,
 98 |         triggerString,
 99 |         // 预留
100 |         supportedLanguages
101 |     }
102 | }
103 | 


--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
 1 | {
 2 | 	"compilerOptions": {
 3 | 		"module": "commonjs",
 4 | 		"target": "es6",
 5 | 		"outDir": "out",
 6 | 		"lib": [
 7 | 			"es6"
 8 | 		],
 9 | 		"sourceMap": true,
10 | 		"rootDir": "src",
11 | 		"strict": true   /* enable all strict type-checking options */
12 | 		/* Additional Checks */
13 | 		// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
14 | 		// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
15 | 		// "noUnusedParameters": true,  /* Report errors on unused parameters. */
16 | 	},
17 | 	"exclude": [
18 | 		"node_modules",
19 | 		".vscode-test"
20 | 	]
21 | }
22 | 


--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
 1 | {
 2 | 	"rules": {
 3 | 		"no-string-throw": true,
 4 | 		"no-unused-expression": true,
 5 | 		"no-duplicate-variable": true,
 6 | 		"curly": true,
 7 | 		"class-name": true,
 8 | 		"semicolon": [
 9 | 			true,
10 | 			"always"
11 | 		],
12 | 		"triple-equals": true
13 | 	},
14 | 	"defaultSeverity": "warning"
15 | }
16 | 


--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
 1 | // @ts-check
 2 | 
 3 | 'use strict';
 4 | 
 5 | const path = require('path');
 6 | 
 7 | /**@type {import('webpack').Configuration}*/
 8 | const config = {
 9 |     target: 'node', // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
10 | 
11 |     entry: './src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
12 |     output: {
13 |         // the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
14 |         path: path.resolve(__dirname, 'out'),
15 |         filename: 'extension.js',
16 |         libraryTarget: 'commonjs2',
17 |         devtoolModuleFilenameTemplate: '../[resource-path]'
18 |     },
19 |     devtool: 'source-map',
20 |     externals: {
21 |         vscode: 'commonjs vscode' // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/
22 |     },
23 |     resolve: {
24 |         // support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
25 |         extensions: ['.ts', '.js']
26 |     },
27 |     module: {
28 |         rules: [
29 |             {
30 |                 test: /\.ts$/,
31 |                 exclude: /node_modules/,
32 |                 use: [
33 |                     {
34 |                         loader: 'ts-loader'
35 |                     }
36 |                 ]
37 |             }
38 |         ]
39 |     }
40 | };
41 | 
42 | module.exports = config;
43 | 


--------------------------------------------------------------------------------