gpt4 book ai didi

regex - 这是什么意思?使用表达式匹配什么字符串?

转载 作者:行者123 更新时间:2023-12-05 01:24:10 24 4
gpt4 key购买 nike

我检查了嘶嘶声代码并看到了一个定义。

var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,

我想知道如何找出这个正则表达式匹配的字符串?

最佳答案

this article .多行正则表达式中的解释:

var chunker = /
(
(?:
# One or more sets of parentheses that contain a string, or another set of
parentheses with a string
\(
(?:
\([^()]+\)
|
[^()]+
)+
\)
|
# Or one or more sets of brackets that contain a string, or another set of
brackets with a string
\[
(?:
\[[^\[\]]*\]
|
['"][^'"]*['"]
|
[^\[\]'"]+
)+
\]
|
# Or a backslash followed by any character
\\.
|
# Or one or more of any except these characters: > +~,([\
[^ >+~,(\[\\]+
)+
# or any one of these characters: >+~
|
[>+~]
)
# followed by zero or one commas, which may be surrounded by whitespace
(\s*,\s*)?
# followed by zero or more of anything, including line endings
((?:.|\r|\n)*)
/g

此表达式包含三个匹配组:“验证”选择器表达式、最终逗号以及之后的所有内容。它将不断地在选择器上被调用以将其分成几部分,参见 Sizzle构造器了解详情。

关于regex - 这是什么意思?使用表达式匹配什么字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11632186/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com