[Regexp] Possible non-conformance with Perl 5 in java distribution of gnu.regexp

Cefn Hoile <[email protected]>
Newsgroups gmane.comp.gnu.regexp
Message-ID <[email protected]>
I have a query on the interpretation of a regular expression within the 
java version of GNU regexp. I think it's a bug, but I may be wrong.

The expression I am trying to reproduce is equivalent to the foillowing 
which I verified in a Perl5 script interpreter...

#!/usr/bin/perl
while(<>){
   $contents = $_;
   $contents =~ s/ *(,*) *gzip *(\1*),* */\2/;
   print "$contents";
}

...and should remove the entry gzip from a comma separated list, whilst 
tidying up the commas (in other words it substitutes a comma if gzip is 
bounded on both sides by commas, otherwise it substitutes the empty 
string if gzip is at the start or end of the list), so...


gzip, deplace:dfokj
slkkf, gzip, las;kj
slkjf, lkhjassd , gzip

...gets processed by the perl script to...

deplace:dfokj
slkkf,las;kj
slkjf, lkhjassd

The perl VM which processes this accurately shows the following version 
information...

perl, v5.8.1-RC3

My code do define the RE and its substitute looks like this currently...

             ACCEPT_ZIP_PATTERN = new RE(" *(,*) *gzip *(\1*),* *");
             ACCEPT_ZIP_SUBSTITUTE = "\2";
             processed_content_types =
                 
ACCEPT_ZIP_PATTERN.substituteAll(processed_content_types, 
ACCEPT_ZIP_SUBSTITUTE);

The equivalent values which I have attempted within the java PERL5 
interpreter include...

Multiple different combinations of the backreferences 1 and 2 using 
either \ or $ to represent them.
Switching to the RE_PERL_5_S syntax instead of the default RE_PERL_5 to 
see if that changed anything.

I spent ages trying to debug why it didn't work in java before I 
verified it in the real perl engine. Now I am concerned that the java 
engine is actually not conformant with PERL5

Alternatively what am I doing wrong to invoke backreferences in the 
java distribution of gnu.regexp?

Cefn
http://cefn.com

_______________________________________________
Gnu-regexp-users mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnu-regexp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.