You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oro-user@jakarta.apache.org by Mark Hollatz-D26 <mh...@cas.org> on 2002/05/10 17:58:50 UTC
backreference not working
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";
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: backreference not working
Posted by Paul R Brown <pr...@fivesight.com>.
> Any suggestions?
Use two backslashes. :)
-- Paul
> if (perl.match("m|<(B6.*?)>.*</\1>|", input_data)) {
^
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>