regexppECMAScript 的正则表达式解析器
regexpp 是一个适用于 ECMAScript 的正则表达式解析器。
安装
$ npm install regexpp
- 需要 Node.js 8 或更新版本。
用法
import { AST, RegExpParser, RegExpValidator, RegExpVisitor, parseRegExpLiteral, validateRegExpLiteral, visitRegExpAST } from "regexpp"
parseRegExpLiteral
解析给定的正则表达式文字,然后生成 AST 对象。
这相当于new RegExpParser(options).parseLiteral(source)
.
- 参数:
-
source
(string | RegExp
) 要解析的源代码。 -
options?
(RegExpParser.Options
) 要解析的选项。
-
- 返回:
- 正则表达式的 AST。
validateRegExpLiteral
验证给定的正则表达式。
这相当于new RegExpValidator(options).validateLiteral(source)
.
- 参数:
-
source
(string
) 要验证的源代码。 -
options?
(RegExpValidator.Options
) 要验证的选项。
-
访问 RegExpAST
访问给定 AST 的每个节点。
这相当于new RegExpVisitor(handlers).visit(ast)
.
- 参数:
-
ast
(AST.Node
) 要访问的 AST。 -
handlers
(RegExpVisitor.Handlers
) 回调。
-
正则解析器
新的 RegExpParser
- 参数:
-
options?
(RegExpParser.Options
) 要解析的选项。
-
parser.parseLiteral
解析正则表达式文字。
- 参数:
-
source
(string
) 要解析的源代码。例如"/abc/g"
。 -
start?
(number
) 源代码中的起始索引。默认为0
。 -
end?
(number
) 源代码中的结束索引。默认为source.length
。
-
- 返回:
- 正则表达式的 AST。
parser.parsePattern
解析正则表达式模式。
- 参数:
-
source
(string
) 要解析的源代码。例如"abc"
。 -
start?
(number
) 源代码中的起始索引。默认为0
。 -
end?
(number
) 源代码中的结束索引。默认为source.length
。 -
uFlag?
(boolean
) 启用 Unicode 模式的标志。
-
- 返回:
- 正则表达式模式的 AST。
parser.parseFlags
解析正则表达式标志。
- 参数:
-
source
(string
) 要解析的源代码。例如"gim"
。 -
start?
(number
) 源代码中的起始索引。默认为0
。 -
end?
(number
) 源代码中的结束索引。默认为source.length
。
-
- 返回:
- 正则表达式标志的 AST。
评论
jStyleParserJava 的 CSS 解析器
jStyleParser 是一个开源 Java 的 CSS 解析器,可以在 Java 程序中解析 C
jStyleParserJava 的 CSS 解析器
0
chtml-matcherLisp的HTML解析器
chtml-matcher 是一个 Lisp 的库用来从 HTML 文档中抽取信息,它使用 clos
chtml-matcherLisp的HTML解析器
0
marky-markdownnpm 的 markdown 解析器
marky-markdown 是 npm 的官方 markdown 解析器,基于 NodeJS 编写
marky-markdownnpm 的 markdown 解析器
0
jFeedjQuery的RSS解析器
jFeed是一个通用的RSS/ATOM解析器jQuery插件jFeed支持RSS0.91,0.92,1.0,2.0和Atom1.0等格式。使用方法:jQuery.getFeed(options);
jFeedjQuery的RSS解析器
0
CSSPoolRuby的CSS解析器
CSSPool是一个Ruby用于解析CSS的工具包,示例代码:require'csspool'sac=CSS::SAC::Parser.newdoc=sac.parse(DATA.read)doc.r
CSSPoolRuby的CSS解析器
0
JerryJava的HTML解析器
Jerry是Jodd工具包中的一个HTML解析工具。它有点像是用Java实现的jQuery。Jerry是一个高效简洁的Java库,用来简化HTML的解析,遍历和操作。Jerry的API在设计的时候完全
JerryJava的HTML解析器
0