32 // Is it a simple selector
33 isSimple =/^. [^: # \ [\.,] * $/
// Indicates that this is a regular expression.
^ Indicates the start part.
$ Indicates the end part.
. Match any character except \ n
[^ Character_group] indicates that it is not in the character set.
[^: # \ [\.,] Indicates any character except the colon (:), #, brackets ([), periods (.), and commas (,).
[^: # \ [\.,] * Indicates the repetition of any of the above characters from 0 to any times.
29 // A simple way to check for HTML strings or ID strings
30 // (both of which we optimize)
31 var quickExpr =/^ [^ <] * (<(. | \ s) +>) [^>] * $ | ^ # (\ w +) $ /;
The content of the regular expression is ^ [^ <] * (<(. | \ s) +>) [^>] * $ | ^ # (\ w +) $
| Or, the expression is divided into two parts.
^ [^ <] * (<(. | \ S) +>) [^>] * $
[^ <] Indicates any character except <
[^ <] * Indicates any number of characters except <
\ S indicates any blank characters, such as spaces, carriage return, and tabulation.
. | \ S represents any character
(. | \ S) + represents any number of characters. Note that it is greedy because it is a plus.
<(. | \ S) +> indicates that the string starts with <, and any character in the middle ends with>, which is the longest string that begins with <and ends with>.
[^>] * Indicates any number of characters except>
In combination, it means that there are multiple arbitrary characters except <, starting with any string in the middle, followed by>, finally, it is a string of any number of characters except>, that is, an html string.
Followed by ^ # (\ w + )&
\ W represents any word character, that is, a [a-zA-Z_0-9].
\ W + indicates more than 1 Character
# (\ W +) indicates more than one word character starting with #, that is, the ID format in jQuery.
Three parentheses are used to indicate the group. If the first group is matched, the subscript is 1, and the third group is matched, the ID is used.
Source: blog