jakarta-regexp-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefán F. Stefánsson <stef...@snote.decode.is>
Subject Bug in count parts of a regular expression.
Date Wed, 11 Apr 2001 16:43:33 GMT
Hello.

I've come across a bug that I think best describes itself.

public static void main(String args[])
{
    String regExp = "([:digit:]{2}[ /]?){3}[ /]?[:digit:]{4}";
    System.out.println( regExp );

    RE ISKtPattern = new RE( regExp );

    //This turns out to be malformed, it leaves the "14/".
    System.out.println( ISKtPattern.subst( "Lorem 14/03/77 4229 ipsum",
"WOOHOO!!!" ) );

    regExp = "([:digit:][:digit:][ /]?){3}[ /]?[:digit:]{4}";
    System.out.println( regExp );

    ISKtPattern = new RE( regExp );

    //This, however, runs just fine!
    System.out.println( ISKtPattern.subst( "Lorem 14/03/77 4229 ipsum",
"WOOHOO!!!" ) );
}

This will give you the output:

([:digit:]{2}[ /]?){3}[ /]?[:digit:]{4} 
Lorem 14/WOOHOO!!! ipsum 
([:digit:][:digit:][ /]?){3}[ /]?[:digit:]{4} 
Lorem WOOHOO!!! ipsum


Shouldn't these two regular expressions yield the same result?

Kind regards,
	Stefan.
--------------------------------------------
Stefan Freyr Stefansson
Software Developer
deCODE Genetics, Inc.
http://www.decode.com

Phone: (+354) 570 2854
GSM:   (+354) 861 1718
Fax:   (+354) 491 3782
 
 <<Stefan Stefansson.vcf>> 

Mime
View raw message