You are viewing a plain text version of this content. The canonical link for it is here.
Posted to regexp-dev@jakarta.apache.org by "Stefán F. Stefánsson" <st...@snote.decode.is> on 2001/04/11 18:43:33 UTC
Bug in count parts of a regular expression.
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>>