This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Prefer \g1 over \1 in pods
[perl5.git] / pod / perlrequick.pod
index ded1e6c..1fde558 100644 (file)
@@ -298,13 +298,13 @@ indicated below it:
      1  2      34
 
 Associated with the matching variables C<$1>, C<$2>, ... are
-the B<backreferences> C<\1>, C<\2>, ...  Backreferences are
+the B<backreferences> C<\g1>, C<\g2>, ...  Backreferences are
 matching variables that can be used I<inside> a regex:
 
-    /(\w\w\w)\s\1/; # find sequences like 'the the' in string
+    /(\w\w\w)\s\g1/; # find sequences like 'the the' in string
 
-C<$1>, C<$2>, ... should only be used outside of a regex, and C<\1>,
-C<\2>, ... only inside a regex.
+C<$1>, C<$2>, ... should only be used outside of a regex, and C<\g1>,
+C<\g2>, ... only inside a regex.
 
 =head2 Matching repetitions
 
@@ -347,7 +347,7 @@ Here are some examples:
 
     /[a-z]+\s+\d*/;  # match a lowercase word, at least some space, and
                      # any number of digits
-    /(\w+)\s+\1/;    # match doubled words of arbitrary length
+    /(\w+)\s+\g1/;    # match doubled words of arbitrary length
     $year =~ /\d{2,4}/;  # make sure year is at least 2 but not more
                          # than 4 digits
     $year =~ /\d{4}|\d{2}/;    # better match; throw out 3 digit dates