develooper Front page | perl.perl5.porters | Postings from June 2013

Regex \8 and \9 after literals no longer work

Thread Next
From:
Michael Schroeder
Date:
June 25, 2013 14:55
Subject:
Regex \8 and \9 after literals no longer work
Message ID:
20130625145508.GB8458@suse.de

Hi Porters,

commit #726ee55d breaks matching of \8 and \9 if they come after a 
literal:

    use re 'debug';
    my $a = '(((((((((x)))))))))foo\9';
    my $b = 'xfoox';
    $b =~ /$a/;

Output:

Final program:
   1: OPEN1 (3)
   3:   OPEN2 (5)
   5:     OPEN3 (7)
   7:       OPEN4 (9)
   9:         OPEN5 (11)
  11:           OPEN6 (13)
  13:             OPEN7 (15)
  15:               OPEN8 (17)
  17:                 OPEN9 (19)
  19:                   EXACT <x> (21)
  21:                 CLOSE9 (23)
  23:               CLOSE8 (25)
  25:             CLOSE7 (27)
  27:           CLOSE6 (29)
  29:         CLOSE5 (31)
  31:       CLOSE4 (33)
  33:     CLOSE3 (35)
  35:   CLOSE2 (37)
  37: CLOSE1 (39)
  39: EXACT <foo9> (41)
  41: END (0)

Note the "foo9" exact match. A workaround is to use \g9, of course,
but the perlre man page says: "C<\1> through C<\9> are always
interpreted as backreferences".

(The change breaks the latex2html package, btw.)

Cheers,
  Michael.

-- 
Michael Schroeder                                   mls@suse.de
SUSE LINUX Products GmbH,  GF Jeff Hawn, HRB 16746 AG Nuernberg
main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);}

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About