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 larry hamel <or...@codeguild.com> on 2002/03/03 08:03:51 UTC
parentheses bug?
hi,
can you tell me if this is a bug, or whether I'm doing something wrong?
using oro 2.0.5, the java test code below yields:
no match: (10.0.0.7)
match: 10.0.0.7
in other words, input with parentheses around the target seems to cause the match to fail. The perl program at the bottom succeeds in both cases, using perl 5.6.1.
thanks,
larry
---------------------------
import org.apache.oro.text.regex.*;
public class TestRegExp {
/**
* a weak pattern for ip address;
* unfortunately will match illegal addresses like 999.999.999.999
*/
public final static String IP_ADDRESS_REGEXP = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}";
private Perl5Matcher mMatcher = new Perl5Matcher();
private Pattern mIP_Pattern = null;
public TestRegExp() throws Exception {
mIP_Pattern = new Perl5Compiler().compile(IP_ADDRESS_REGEXP);
System.out.println(match("(10.0.0.7)"));
System.out.println(match("10.0.0.7"));
}
private String match( String toMatch ) {
if ( mMatcher.matches(toMatch, mIP_Pattern ) ) {
// MatchResult result = mMatcher.getMatch();
return ("match: " + toMatch);
} else {
return ("no match: " + toMatch);
}
}
public static void main(String[] args) throws Exception {
TestRegExp testRegExp = new TestRegExp();
}
}
--------------
#!/usr/bin/perl
#
if( "(10.0.0.7)" =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ ){
print "match" ;
} else {
print "no match";
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: parentheses bug?
Posted by larry hamel <or...@codeguild.com>.
oh, duh.
thanks!
larry
At 11:52 PM 3/2/2002, you wrote:
>In message <5....@mail.codeguild.com>, larry hamel
> writes:
>> private String match( String toMatch ) {
>> if ( mMatcher.matches(toMatch, mIP_Pattern ) ) {
>
>You mean to use contains().
>
>daniel
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>