SoFunction
Updated on 2025-03-03

Regular expression analysis in jQuery Regular basis

quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/
(?:…) means it is a non-capture type

[^<] means that it starts with "<" and contains 0 or more '<' brackets

(<[\w\W]+>) means a capture type, starting with '<>', containing one or more characters in the middle.

$ means the end of a character

(#([\w\-]+)) means a capture type, composed of '#' number and string, number, _ and -

rnotwhite = /\S/
\S means a symbol other than a blank character

trimLeft = /^\s+/trimRight = /\s+$/
Blanks on the left and right sides. s is a whitespace character. The ^ prefix indicates the beginning of the string, and the $ suffix indicates the end of the string

rdigit = /\d/
Indicates that it is a number

rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/
^<(\w+)\s*\/?>
It starts with '<', contains one to multiple characters, and 0 to multiple blanks, 0 or one '/' and '>',

(?:<\/\1>)?$

Indicates that the end of the first capture type exists or does not exist