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');
result = Regex.contain('http://item.taobao.com/item.htm?spm=2013.1.w1057672648.1.zlrrXo&id=21482588062', 'item.taobao.com/item.htm');
Package Sidebar
Install
Weekly Downloads