When I read the jquery code, I see a regular expression definition
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/
Rsingletag is used to match simple HTML tags,
There is a non-capturing group:
(?:<\/\1>), here's the question:
Why use non-capturing groupings, and what if not?
For example, you can also use a non-capturing grouping in this regular expression:
rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/
Why use non-capturing groupings?
Where is the regular expression used?
Reply content:
When I read the jquery code, I see a regular expression definition
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/
Rsingletag is used to match simple HTML tags,
There is a non-capturing group: (?:<\/\1>) The problem is:
Why use non-capturing groupings, and what if not?
For example, you can also use a non-capturing grouping in this regular expression:
rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/
Why use non-capturing groupings?
Where is the regular expression used?
Then ask yourself what is a non-capturing group, and where do you know this "noun"?
So the question is, what's a non-capturing group?
Is the grouping you don't want to be caught in, in JS, the character that a brace is wrapped in is a grouping. Sometimes you have to use parentheses to group the same type of characters when writing a regular, for example /(abc){3}/ , ABC three letters match three times, and ABC is the same type of character. However, this set of characters is not required in match or exec or replace and so on, so it is not captured. Think about the following demand
There is a string, using n ABCD plus a section of other characters, and now I want to write a string of n abcd behind
For example abcdabcdabcdefg , you want EFG.
'abcdabcdabcdefg'.match(/(abcd)+(.+)/) => ["abcdabcdabcdefg", "abcd", "efg"]'abcdabcdabcdefg'.match(/(?:abcd)+(.+)/) => ["abcdabcdabcdefg", "efg"]
Do not write as if you can get it, but when you are writing a very long time, there will be a lot of useless results, watching all headaches.
=============
Add a sentence, you ask these questions, you put the console out, add the?: and the results of the output once did not know.