backreference not working

Mark Hollatz-D26 <[email protected]> Fri, 10 May 2002 11:58:50 -0400 (EDT)
Newsgroups gmane.comp.jakarta.oro.user
Message-ID <[email protected]>
In the program below I match an open XML tag and try
to use a backreference to match the corresponding
close tag, however it is not working.  The backreference
is causing it to fail.  If I replace it with "...." the
RE matches.  I am using Jakarata 2.0.6.

The backreference works in my Perl version (included below)
of this test.

Any suggestions?

Mark



import org.apache.oro.text.regex.*;
import org.apache.oro.text.perl.*;

public class OROTest {
	public static void main(String[] args)
	{
		Perl5Util perl = new Perl5Util();
		String input_data = "<B630>foo</B630>";
		String found_tag;

		System.out.println("looking...");
		if (perl.match("m|<(B6.*?)>.*</\1>|", input_data)) {
			found_tag = perl.group(1);
			System.out.println("matched tag: " + found_tag);
		}
	}
}


#!/usr/perl5/bin/perl
$input_data = "<B630>foo</B630>";
print "looking...\n";
if ($input_data =~ m|<(B6.*?)>.*</\1>|) {
	print "matched tag: $1\n";
}