Back to rankings

cdoco/common-regex

:jack_o_lantern: 常用正则表达式 - 收集一些在平时项目开发中经常用到的正则表达式。

regexcommon-regexregexpregex-validator
Star Growth
Stars
3.1k
Forks
409
Weekly Growth
Issues
6
1k2k3k
Mar 2017Apr 2020Jun 2023Jul 2026
README

目录

邮箱

gaozihang-001@gmail.com 只允许英文字母、数字、下划线、英文句号、以及中划线组成

^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$

email

高子航001Abc@bowbee.com.cn 名称允许汉字、字母、数字,域名只允许英文域名

^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$

email

电话

13012345678 手机号

^1(3|4|5|6|7|8|9)\d{9}$

phone

XXX-XXXXXXX XXXX-XXXXXXXX 固定电话

(\(\d{3,4}\)|\d{3,4}-|\s)?\d{8}

email

域名

https://google.com/

^((http:\/\/)|(https:\/\/))?([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}(\/)

domain-name

IP

127.0.0.1

((?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d))

ip

帐号校验

gaozihang_001 字母开头,允许5-16字节,允许字母数字下划线

^[a-zA-Z][a-zA-Z0-9_]{4,15}$

user

字符校验

汉字

高子航

^[\u4e00-\u9fa5]{0,}$

chinese

英文和数字

^[A-Za-z0-9]+$

char

长度为3-20的所有字符

^.{3,20}$

char

英文字符

由26个英文字母组成的字符串

^[A-Za-z]+$

char

由26个大写英文字母组成的字符串

^[A-Z]+$

char

由26个小写英文字母组成的字符串

^[a-z]+$

char

由数字和26个英文字母组成的字符串

^[A-Za-z0-9]+$

char

由数字、26个英文字母或者下划线组成的字符串

^\w+$

char

中文、英文、数字包括下划线

^[\u4E00-\u9FA5A-Za-z0-9_]+$

char

中文、英文、数字但不包括下划线等符号

^[\u4E00-\u9FA5A-Za-z0-9]+$

char

禁止输入含有%&',;=?$"等字符

[^%&',;=?$\x22]+

char

禁止输入含有~的字符

[^~\x22]+

char

数字正则

整数

^-?[1-9]\d*$

num

正整数

^[1-9]\d*$

num

负整数

^-[1-9]\d*$

num

非负整数

^[1-9]\d*|0$

num

非正整数

^-[1-9]\d*|0$

num

浮点数

^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$

num

正浮点数

^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$

num

负浮点数

^-([1-9]\d*\.\d*|0\.\d*[1-9]\d*)$

num

非负浮点数

^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$

num

非正浮点数

^(-([1-9]\d*\.\d*|0\.\d*[1-9]\d*))|0?\.0+|0$

num

License

MIT License. See the LICENSE file.

⬆ top

Related repositories
BurntSushi/ripgrep

ripgrep recursively searches directories for a regex pattern while respecting your gitignore

Rustcrates.ioThe Unlicenseripgreprecursively-search
66.4k2.7k
ziishaned/learn-regex

Learn regex the easy way

MIT Licenseregexregular-expression
gum.co/learn-regex
46.1k6.1k
sharkdp/fd

A simple, fast and user-friendly alternative to 'find'

Rustcrates.ioApache License 2.0command-linetool
43.8k1.1k
Blankj/AndroidUtilCode

:fire: Android developers should collect the following utils(updating).

JavaMavenApache License 2.0androidapp
blankj.com/2016/07/31/android-utils-code/
33.7k10.6k
dottxt-ai/outlines

Structured Outputs

PythonPyPIApache License 2.0generative-aillms
dottxt-ai.github.io/outlines/
14.9k800
learnbyexample/Command-line-text-processing

:zap: From finding text to search and replace, from sorting to beautifying text and more :art:

Shellcommand-linelinux
10.2k704
any86/any-rule

🦕 常用正则大全, 支持web / vscode / idea / Alfred Workflow多平台

TypeScriptnpmMIT Licensezheng-zeregexp
any-rule.vercel.app
8.7k811
pemistahl/grex

A command-line tool and Rust library with Python bindings for generating regular expressions from user-provided test cases

Rustcrates.ioApache License 2.0command-line-tooltool
pemistahl.github.io/grex-js/
8.2k196
chmln/sd

Intuitive find & replace CLI (sed alternative)

Rustcrates.ioMIT Licensecommand-linerust
7.3k163
CJex/regulex

:construction: Regular Expression Excited!

TypeScriptnpmMIT Licensejavascriptregulex
jex.im/regulex/
5.8k754
intel/hyperscan

High-performance regular expression matching library

C++Otherregex
hyperscan.io
5.4k808
VincentSit/ChinaMobilePhoneNumberRegex

Regular expressions that match the mobile phone number in mainland China. / 一组匹配中国大陆手机号码的正则表达式。

MIT Licensephone-numberregular-expression
4.8k508