Regular, / ^\ s + |\ smatches / and / ^ (\ s +) |\ 1matches / why the matching results are not the same.

/^\s+|\s+$/
/^(\s+)|\1$/

^[A-Z]|\[A-Z]$ 
^([A-Z])|\1$ 

I don"t know where to understand the problem, the problem of symbol priority? Or something else, if anyone can answer, thank you very much.

Mar.02,2021

is really a misunderstanding. For a moment, the reference to the backward reference is not the rule, but the matching content in the rule in the previous grouping.


refers to the content matched by the grouping, not the rules of the grouping

Menu