1.0.0 • Published 11 years ago

yi-regex v1.0.0

Weekly downloads
9
License
-
Repository
github
Last release
11 years ago

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