Except for the capture group syntax, other (?...) The syntax is not the verification of the capture group.
See the following content in a regular expression technical document:
"It must be noted that apart from (Expression) and (? <Name> Expression) syntax, other (?...) Neither of the syntax is a capture group ."
This content is understandable, but I am confused that the author of this article, in another technical article on related regular expressions, is an example of this, which really puzzles me:
Text Content
<td>a</td><td>b</td>
Regular Expression
(?is)<td>(?:(?!</td>).)*</td>
Pay attention to the code of the regular expression above. </Td>). "force a non-capturing group. I told him in the text message that it could be written as follows :(? Is) <td> ((?! </Td>).) * </td>
Two days later, I still didn't see him reply, so I looked back at his code. At first I focused on "(?! </Td>) "This bracket is not a capture group. However, I only reflected the code in the above technical article once. He is not targeting (?! </Td>) force (?! </Td>). The force is not a capture group, so I did the following test:
Text Content
<td>a</td><td>a</td>
Regular Expression
<td>((?!</td>).)*</td><td>(\1)*</td>
Matching result
<td>a</td><td>a</td>
This proves that, if not, "(?! </Td>). "to force a non-capturing group, it will be captured, and I don't need it at all.
Next, I'm testing, except (Expression) and (? <Name> Expression) except the syntax, for example, loop view, it is not a capture group.
Text Content
<td>a</td><td>a</td>
Regular Expression
<td>((?!</td>).)*</td><td>(\2.)*</td>
Matching result: Mismatch
If you have different opinions, please discuss them.