JQuery_2.1.0_日記 5.4 Sizzle選擇器(二)

(1)
whitespace = "[\\x20\\t\\r\\n\\f]";
匹配css3中空白符.
\x20:空格;\t水平製表符(tab);\r\n回車換行\f換頁符

(2)
characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+"
匹配\後任意字符,字母或數字或-,ascii值非\00-\xa0範圍內的字符

(3)
identifier = characterEncoding.replace( "w" , "w#" )
匹配\後任意字符,字母或數字或#或-,ascii值非\00-\xa0範圍內的字符

(4)
attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
               "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]"
   匹配屬性選擇器,例如:[arr^='val']
   捕獲組1:characterEncoding :匹配例子中arr
   捕獲組2:([*^$|!~]?=):匹配例子中^=
   捕獲組3:['\"]:匹配例子中'
   捕獲組4:(?:\\\\.|[^\\\\])*? 解釋一下這個外層捕獲\和後面的任意數量字符或非\字符,內層有?:是不捕獲的,匹配例子中的val
   捕獲組5:匹配identifier,匹配[id=#a]的情況
(5)
pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)"
   匹配僞類表達式,例如li:nth-child(2n+1)
   捕獲組1:characterEncoding :匹配例子中nth-child
   捕獲組2:匹配例子中的2n+1
   捕獲組3:匹配' or "
   捕獲組4:匹配\和後面任何字符或非\字符
   捕獲組5:匹配不再' or "內的\和後面任意字符或非\()[]字符或attributes

(6)
rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" )
   捕獲 > + ~ 關係符
(7)
rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]" , "g" )
    匹配=[非'非"]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章