grep: Back-references and Subexpressions
1
1 3.5 Back-references and Subexpressions
1 ======================================
1
1 The back-reference ‘\N’, where N is a single digit, matches the
1 substring previously matched by the Nth parenthesized subexpression of
1 the regular expression. For example, ‘(a)\1’ matches ‘aa’. When used
1 with alternation, if the group does not participate in the match then
1 the back-reference makes the whole match fail. For example, ‘a(.)|b\1’
1 will not match ‘ba’. When multiple regular expressions are given with
1 ‘-e’ or from a file (‘-f FILE’), back-references are local to each
1 expression.
1