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 🙏

© 2026 – Pkg Stats / Ryan Hefner

mm_matchs

v1.1.8

Published

这是用来匹配复杂的字符串结构的函数,可以匹配前缀包含、后缀包含、以及时间、地点等

Downloads

81

Readme

mm_matchs

这是一个用于匹配复杂字符串结构的Node.js模块,提供了丰富的字符串匹配功能,可以匹配前缀包含、后缀包含、以及时间、地点等多种模式。

特点

  • 支持多种匹配模式:前缀匹配、后缀匹配、正则匹配等
  • 内置丰富的匹配规则:时间、日期、地点、网址等
  • 使用简单,支持链式调用
  • 可扩展性强,支持自定义匹配规则

安装

npm install mm_matchs

基础用法

const Matchs = require('mm_matchs');
const ms = new Matchs();

// 使用String原型扩展方法
const str = "我叫文武, 手机号码是15817188866";

// 前缀匹配
console.log(str.matchs('手机号码*'));  // 15817188866

// 后缀匹配
console.log(str.matchs('*武'));  // 文武

// 区间匹配
console.log(str.matchs('如果*就*'));  // 匹配两个通配符之间的内容

内置匹配规则

时间日期类

// 匹配日期时间
str = "1991-04-01 12:15:36";
console.log(str.matchs('{日期时间}'));

// 匹配年月日
str = "1991年4月1日";
console.log(str.matchs('{年月日}'));

// 匹配时间
str = "现在的时间是19:35:59";
console.log(str.matchs('{时间}'));

地理位置类

// 匹配省份
str = "广东省深圳市南山区";
console.log(str.matchs('{省份}'));

// 匹配城市
console.log(str.matchs('{城市}'));

// 匹配方位
console.log(str.matchs('{方位}'));

网络通信类

// 匹配网址
console.log("http://www.example.com".matchs('{网址}'));

// 匹配邮箱
console.log("[email protected]".matchs('{邮箱}'));

// 匹配手机号码
console.log("13812345678".matchs('{手机号码}'));

其他常用匹配

// 匹配身份证号
console.log("440123199001011234".matchs('{身份证号}'));

// 匹配车牌号
console.log("粤B12345".matchs('{车牌号}'));

// 匹配中英文
console.log("Hello世界".matchs('{中英文}'));

API文档

主要方法

  • matchs(pattern): 字符串匹配方法,支持通配符和预定义规则
  • tense(str, format): 匹配时态
  • bearing(str, format): 匹配方位
  • province(str, format): 匹配省份
  • city(str, format): 匹配城市

预定义规则

模块内置了多种匹配规则,使用花括号{}包裹规则名称:

  • {日期时间}: 匹配日期时间格式
  • {日期}: 匹配日期
  • {时间}: 匹配时间
  • {网址}: 匹配URL
  • {邮箱}: 匹配电子邮箱
  • {手机号码}: 匹配手机号
  • {身份证号}: 匹配身份证号码
  • {车牌号}: 匹配车牌号
  • {中英文}: 匹配中英文混合

许可证

ISC License

作者

qww