加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 05:50:07 所属栏目:百科 来源:网络整理
导读:我查看了sizzle代码并查看了一个定义. var chunker = /((?:((?:([^()]+)|[^()]+)+)|[(?:[[^[]]*]|['"][^'"]*['"]|[^[]'"]+)+]|.|[^ +~,([]+)+|[+~])(s*,s*)?((?:.|r|n)*)/g, 我想知道如何找出这个正则表达式匹配的字符串? 解决方法 请
我查看了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构造函数.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读