{"id":13842569,"url":"https://github.com/secoba/SomePubRegex","last_synced_at":"2025-07-11T15:32:07.992Z","repository":{"id":112214750,"uuid":"217879944","full_name":"secoba/SomePubRegex","owner":"secoba","description":"Some useful regexes","archived":false,"fork":false,"pushed_at":"2020-03-20T15:56:16.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-21T13:36:32.712Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/secoba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-10-27T16:04:01.000Z","updated_at":"2020-12-02T02:16:40.000Z","dependencies_parsed_at":"2023-05-11T09:00:32.852Z","dependency_job_id":null,"html_url":"https://github.com/secoba/SomePubRegex","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/secoba/SomePubRegex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secoba%2FSomePubRegex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secoba%2FSomePubRegex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secoba%2FSomePubRegex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secoba%2FSomePubRegex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/secoba","download_url":"https://codeload.github.com/secoba/SomePubRegex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secoba%2FSomePubRegex/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264841049,"owners_count":23671809,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T17:01:40.029Z","updated_at":"2025-07-11T15:32:07.651Z","avatar_url":"https://github.com/secoba.png","language":null,"funding_links":[],"categories":["Others (1002)","Others"],"sub_categories":[],"readme":"## Some useful regexes\n\n\u003e Collecting some useful regex string, if you know some, pls tell me. :)\n\n---\n\n[TOC]\n\n#### 用户名 (username)\n```text\n^[a-z0-9_-]{3,16}$\n```\n\n#### 密  码 (password)\n```text\n^[a-z0-9_-]{6,18}$\n```\n\n#### 16进制数 (Hex value)\n```text\n^#?([a-f0-9]{6}|[a-f0-9]{3})$\n```\n\n#### 校验密码强度 (password strength check)\n\u003e 密码的强度必须是包含大小写字母和数字的组合，不能使用特殊字符，长度在8-10之间\n```text\n^(?=.*\\\\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$\n```\n\n#### 校验中文 (verify chinese)\n\u003e 字符串仅能是中文。\n```text\n^[\\\\u4e00-\\\\u9fa5]{0,}$\n```\n\n#### 由数字、字母或下划线 (only number、letter or underline)\n\u003e 由数字、字母或下划线组成的字符串\n```text\n^\\\\w+$\n```\n\n#### 手机号码 (CN-phone number)\n\u003e 下面是国内 13、15、18开头的手机号正则表达式。\n```text\n^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\\\d{8}$\n```\n\n#### 校验身份证号码 (CN-identity card)\n\u003e 身份证号码的正则校验(15 或 18位)\n\n##### 15位\n```text\n^[1-9]\\\\d{7}((0\\\\d)|(1[0-2]))(([0|1|2]\\\\d)|3[0-1])\\\\d{3}$\n```\n\n##### 18位\n```text\n^[1-9]\\\\d{5}[1-9]\\\\d{3}((0\\\\d)|(1[0-2]))(([0|1|2]\\\\d)|3[0-1])\\\\d{3}([0-9]|X)$\n```\n\n#### 邮箱地址 (email address)\n\u003e email地址合规性的正则检查语句\n```text\n^([a-z0-9_\\.-]+)@([\\da-z\\.-]+)\\.([a-z\\.]{2,6})$\n\n^[a-z\\d]+(\\.[a-z\\d]+)*@([\\da-z](-[\\da-z])?)+(\\.{1,2}[a-z]+)+$\n\n[\\\\w!#$%\u0026'*+/=?^_`{|}~-]+(?:\\\\.[\\\\w!#$%\u0026'*+/=?^_`{|}~-]+)*@(?:[\\\\w](?:[\\\\w-]*[\\\\w])?\\\\.)+[\\\\w](?:[\\\\w-]*[\\\\w])?\n```\n\n#### 校验日期 (verify datetime \"yyyy-mm-dd\" format)\n\u003e \"yyyy-mm-dd\" 格式的日期校验，已考虑平闰年\n```text\n^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$\n```\n\n#### 提取页面超链接 (get url address)\n\u003e 提取html中的超链接\n```text\n(\u003c;a\\\\s*(?!.*\\\\brel=)[^\u003e;]*)(href=\"https?://)((?!(?:(?:www\\\\.)?'.implode('|(?:www\\\\.)?', $follow_list).'))[^\"]+)\"((?!.*\\\\brel=)[^\u003e;]*)(?:[^\u003e;]*)\u003e\n```\n\n#### 抽取注释 (get html comment)\n\u003e 查找HMTL中的注释\n```text\n\u003c!--(.*?)--\u003e\n```\n\n#### 匹配HTML标签 (matching html tag)\n\u003e 匹配出HTML中的标签。\n```text\n\u003c/?\\\\w+((\\\\s+\\\\w+(\\\\s*=\\\\s*(?:\".*?\"|'.*?'|[\\\\^'\"\u003e\\\\s]+))?)+\\\\s*|\\\\s*)/?\u003e\n```\n\n#### 验证域名 (verify domain)\n\u003e 匹配完整域名\n```text\n^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$\n```\n\n#### Win文件路径及扩展名校验 (verify win path and extension)\n\u003e 验证文件路径和扩展名\n```text\n^([a-zA-Z]\\\\:|\\\\\\\\)\\\\\\\\([^\\\\\\\\]+\\\\\\\\)*[^\\\\/:*?\"\u003c\u003e|]+\\\\.txt(l)?$\n\n# import re\n# regx = \"\"\"^([a-zA-Z]\\\\:|\\\\\\\\)\\\\\\\\([^\\\\\\\\]+\\\\\\\\)*[^\\\\/:*?\"\u003c\u003e|]+\\\\.txt(l)?$\"\"\"\n# print(re.match(regx,\"\"\"C:\\\\fewfewfw\\\\fewf\\\\test.txtf\"\"\"))\n```\n\n#### 提取Color Hex Codes (get color hex)\n\u003e 抽取网页中的颜色代码\n```text\n\\\\#([a-fA-F]|[0-9]){3,6}\n```\n\n#### 提取网页图片 (get image address)\n\u003e 提取网页中所有图片\n```text\n\\\\\u003c *[img][^\\\\\u003e]*[src] *= *[\\\\\"\\\\']{0,1}([^\\\\\"\\\\'\\\\ \u003e]*)\n```\n\n#### 校验IPv4地址 (verify ipv4)\n\u003e IP4 正则语句。\n```text\n((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\n\n^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$\n\n\\\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\\\b\n```\n\n#### 校验IPv6地址 (verify ipv6)\n\u003e IP6 正则语句。\n```text\n(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\n```\n\n#### 匹配URL (get url)\n```text\n^(https?:\\/\\/)?([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([\\/\\w \\.-]*)*\\/?$\n```\n\n#### 检查URL的前缀 (get url prefix)\n\u003e 很多时候需要区分请求是HTTPS还是HTTP，通过下面的表达式可以取出一个url的前缀然后再逻辑判断。\n```text\n^[a-zA-Z]+:\\\\/\\\\/\n\n# print(re.findall(\"^[a-zA-Z]+:\\\\/\\\\/\",\"ftp://test.com\"))\n```\n\n#### 校验金额 (verify money)\n\u003e 金额校验，精确到2位小数。\n```text\n^[0-9]+(.[0-9]{2})?$\n```\n\n#### 判断IE的版本 (get IE version)\n\u003e IE目前还没被完全取代，很多页面还是需要做版本兼容，下面是IE版本检查的表达式。\n```text\n^.*MSIE [5-8](?:\\\\.[0-9]+)?(?!.*Trident\\\\/[5-9]\\\\.0).*$\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecoba%2FSomePubRegex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsecoba%2FSomePubRegex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecoba%2FSomePubRegex/lists"}