the regex utils
CoffeeScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
README.md
index.coffee
index.js
package.json

README.md

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');