See the following in a regular expression technical document:
"One point that needs to be noted is that except for (Expression) and (?<name>Expression) syntax, other (?...) syntaxes are not capture groups."
This content is easy to understand, but what is puzzled is that in another technical article about related regularity, one of these examples really confused me:
Text content
<td>a</td><td>b</td>
Regular expressions
(?is)<td>(?:(?!</td>).)*</td>
Pay attention to the code of the regular expression above. It performs a "forced non-capture group" on "(?!</td>)." and I told him in a text message that I can write it like this: (?is)<td>((?!</td>).)*</td>
I haven't seen him reply for two days, so I went back to study his code. At first I focused on whether the bracket "(?!</td>)" is considered a capture group. But after reading the code of the above technical article, I realized it. He did not force (?!</td>) to a non-capture group, but forced (?!</td>). to a non-capture group, so I did the following test:
Text content
<td>a</td><td>a</td>
Regular expressions
<td>((?!</td>).)*</td><td>(\1)*</td>
Match results
<td>a</td><td>a</td>
This proves that if "(?!</td>)." is not forced to be a non-capture group, it will catch, and I don't need it at all.
Next, I'm testing whether other than (Expression) and (?<name>Expression) syntax, such as surround viewing, is it considered a capture group.
Text content
<td>a</td><td>a</td>
Regular expressions
<td>((?!</td>).)*</td><td>(\2.)*</td>
Match result: mismatch
If you have different opinions, please feel free to discuss it.