我查看了sizzle代码并查看了一个定义.
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构造函数.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。