RegJSParser 软件
在JavaScript中解析JavaScript的RegExp.
安装
npm install regjsparser
使用量
var parse = require('regjsparser').parse;
var parseTree = parse('^a'); // /^a/
console.log(parseTree);
// Toggle on/off additional features:
var parseTree = parse('^a', '', {
// SEE: https://github.com/jviereck/regjsparser/pull/78
unicodePropertyEscape: true,
// SEE: https://github.com/jviereck/regjsparser/pull/83
namedGroups: true,
// SEE: https://github.com/jviereck/regjsparser/pull/89
lookbehind: true,
// SEE: https://github.com/jviereck/regjsparser/pull/113
unicodeSet: true,
// SEE: https://github.com/jviereck/regjsparser/pull/127
modifiers: true,
// SEE: https://github.com/jviereck/regjsparser/pull/166
bufferBoundaries: true
});
console.log(parseTree);
测试
要进行测试,请执行以下命令:
npm test
要创建新的引用文件, 执行..
node test/update-fixtures.js
...从顶级目录.