yi-regex

1.0.0 • Public • Published

regex

提供一些常用的正则表达式处理方法。

安装

    npm install yi-regex

引入

Regex = require('yi-regex');

使用

  • match(regex,string)

    regex:正则表达式

    string:需要匹配的字符串

    return:Array匹配结果

result = Regex.match(/id=(\d+)/, 'http://item.taobao.com/item.htm?spm=2013.1.w1057672648.1.zlrrXo&id=21482588062');
  • matchAll(regex,string)

    regex:正则表达式

    string:需要匹配的字符串

    return:Array匹配结果

result = Regex.matchAll(/\w+=[^&]*/g, 'http://item.taobao.com/item.htm?spm=2013.1.w1057672648.1.zlrrXo&id=21482588062');
  • contain(string,substring)

    string:字符串

    substring:子字符串

    return:Boolean 字符串是否包含子串

result = Regex.contain('http://item.taobao.com/item.htm?spm=2013.1.w1057672648.1.zlrrXo&id=21482588062', 'item.taobao.com/item.htm');

Readme

Keywords

none

Package Sidebar

Install

npm i yi-regex

Weekly Downloads

1

Version

1.0.0

License

none

Last publish

Collaborators

  • avicha