正则表达式 – 这是什么意思?使用表达式匹配什么字符串?

我查看了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构造函数.

相关文章

正则替换html代码中img标签的src值在开发富文本信息在移动端...
正则表达式
AWK是一种处理文本文件的语言,是一个强大的文件分析工具。它...
正则表达式是特殊的字符序列,利用事先定义好的特定字符以及...
Python界一名小学生,热心分享编程学习。
收集整理每周优质开发者内容,包括、、等方面。每周五定期发...