npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

reg-expression

v0.0.6

Published

reg expression

Downloads

5

Readme

reg-expression

🚀 reg-expression 🌈.

usage

安装

npm i reg-expression --save

使用

import RegExpression from 'reg-expression'
// or
import { ip_v4 } from 'reg-expression'

const isIPV4 = ip_v4.test('1.1.1.1')
console.log(isIPV4) // true

已提供验证规则

code类

// ip v4
export const ip_v4 = /^((\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])$/
// ip v4 (可加端口)
export const ip_v4_port = /^((\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]))?$/

// ip v6 (可加端口)
export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-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
// 16禁止颜色
export const hex_color = /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/

// 子网掩码
export const netmask = /^(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(?:\.(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/

// 网址(url,支持端口和"?+参数"和"#+参数)
export const url = /^(((ht|f)tps?):\/\/)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?$/
// 必须带端口号的网址(或ip)
export const url_port = /^((ht|f)tps?:\/\/)?[\w-]+(\.[\w-]+)+:\d{1,5}\/?$/

// html注释
export const html_comment = /^<!--[\s\S]*?-->$/

// md5格式(32位)
export const md5 = /^([a-f\d]{32}|[A-F\d]{32})$/

// 版本号(version)格式必须为X.Y.Z
export const version = /^\d+(?:\.\d+){2}$/

// 视频(video)链接地址(视频格式可按需增删)
export const video_src = /^https?:\/\/(.+\/)+.+(\.(swf|avi|flv|mpg|rm|mov|wav|asf|3gp|mkv|rmvb|mp4))$/i
// 图片(image)链接地址(图片格式可按需增删)
export const image_src = /^https?:\/\/(.+\/)+.+(\.(gif|png|jpg|jpeg|webp|svg|psd|bmp|tif))$/i

// base64格式
export const base64 = /^\s*data:(?:[a-z]+\/[a-z0-9-+.]+(?:;[a-z-]+=[a-z0-9-]+)?)?(?:;base64)?,([a-z0-9!$&',()*+;=\-._~:@/?%\s]*?)\s*$/i
// mac物理地址
export const macaddress = /^((([a-f0-9]{2}:){5})|(([a-f0-9]{2}-){5}))[a-f0-9]{2}$/i

user类

// 身份证号
export const id_number = /^[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]$/

// 身份证号(1代,15位数字)
export const id_number_1st = /^[1-9]\d{7}(?:0\d|10|11|12)(?:0[1-9]|[1-2][\d]|30|31)\d{3}$/

// 手机号(严谨型)
export const phone_rigor = /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/
// 手机号(宽松), 只要是13,14,15,16,17,18,19开头即可
export const phone = /^(?:(?:\+|00)86)?1[3-9]\d{9}$/
// 手机号(最宽松), 只要是1开头即可, 如果你的手机号是用来接收短信, 优先建议选择这一条
export const phone_loose = /^(?:(?:\+|00)86)?1\d{10}$/

// email
export const email = /^(([^<>()[\]\\.,;:\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,}))$/

// 座机/电话(国内),如: 0300-86868686
export const telphone = /^(?:(?:\d{3}-)?\d{8}|^(?:\d{4}-)?\d{7,8})(?:-\d+)?$/

// 护照
export const passport = /(^[EeKkGgDdSsPpHh]\d{8}$)|(^(([Ee][a-fA-F])|([DdSsPp][Ee])|([Kk][Jj])|([Mm][Aa])|(1[45]))\d{7}$)/

// QQ号格式
export const qq = /^[1-9][0-9]{4,10}$/

// 微信号(wx),6至20位,以字母开头,字母,数字,减号,下划线
export const wechat_number = /^[a-zA-Z][-_a-zA-Z0-9]{5,19}$/

// 邮政编码(中国)
export const zip_code = /^(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}$/

// 手机机身码(IMEI)
export const IMEI = /^\d{15,17}$/

// 火车车次
export const train_number = /^[GCDZTSPKXLY1-9]\d{1,4}$/

map类

// 经度
export const longitude = /^[-]?(([1-9]\d?)|(1[0-7]\d))(\.\d{0,6})|180|0(\.\d{6,6})$/
// 纬度
export const latitude = /^[-]?(0|([1-9]\d?))(\.\d{0,6})$/

// 经度(度分秒) dms-> degree minute second
export const longitude_dms = /^[W|E]{1}([0-9]{1,3}\°)*([0-9]{1,2}\')*([0-9]{1,2}(\.[0-9]{1,2})*\")*$/
// 纬度(度分秒) dms-> degree minute second
export const latitude_dms = /^[N|S]{1}([0-9]{1,2}\°)*([0-9]{1,2}\')*([0-9]{1,2}(\.[0-9]{1,2})*\")*$/