npm.io
3.0.0 • Published 2 years ago

regexp-utilsjs

Licence
ISC
Version
3.0.0
Deps
0
Size
13 kB
Vulns
0
Weekly
0
Stars
2

regexp-utilsjs

介绍

regexp-utilsjs 是纯 js 正则方法库, 包含:数字,联系方式等。

特性

  • 纯 js

更新日志

[3.0.0]
  • 优化
    • 调整一些方法

安装

# npm:
npm i regexp-utilsjs -S

引入方法

方式一. 自动按需引入 (推荐)

babel-plugin-import 是一款 babel 插件,它会在编译过程中将 import 的写法自动转换为按需引入的方式。

// 安装插件
npm i babel-plugin-import -D

// 在 babel.config.js 中配置
plugins: [
    [
        'import',
        {
            libraryName: 'regexp-utilsjs',
            libraryDirectory: 'lib',
            camel2DashComponentName: false
        },
        'regexp-utilsjs'
    ]
];

// 接着你可以在代码中直接使用
import { numberRegexp } from 'regexp-utilsjs';

numberRegexp.test(123) // true
方式二. 手动按需引入
import numberRegexp from 'regexp-utilsjs/lib/numberRegexp';

numberRegexp.test(123) // true
方式三. 导入所有
import regexpUtilsjs from 'regexp-utilsjs';

regexpUtilsjs.numberRegexp.test(123); // true

文档

正则类型 说明 test replace
numberRegexp 数字
numberPositiveRegexp 正数
numberNegativeRegexp 负数
integerRegexp 整数
integerPositiveRegexp 正整数
integerNegativeiRegexp 负整数
chineseRegexp 中文
englishRegexp 英文
contactRegexp 联系方式,包括手机号和固定电话 ×
emailRegexp 邮箱 ×
idcardRegexp 身份证 ×
internetURLRegexp 网址 ×
landlineRegexp 固定电话 ×
phoneRegexp 手机号 ×

联系方式

链接

Keywords