Bug 10893

Summary: {n.m} notation work incorrect if n=0
Product: Regexp Reporter: Torres Elio <torres>
Component: OtherAssignee: Jakarta Notifications Mailing List <notifications>
Status: CLOSED DUPLICATE    
Severity: normal CC: lefevrol
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   

Description Torres Elio 2002-07-17 14:54:26 UTC
the match-method on RE class work incorrectly if the lower bound in the {n,m}
notation have the value of 0 for n and n<m.

I wrote this test programm to check the erro:

import org.apache.regexp.RE;

public class test
{
  public static void main(String args[])
  {
    try
    {
      test re = new test();
      re.test();
    } catch(Exception e)
    {
    }
  }

  public void test()
    throws Exception
  {
    String[] exprV = {"ab{0,1}","ab{1}"};
    String[] matchV = {"a","aa","aba","abba"};
    boolean matched;
    RE r;
    System.out.println("expr \tmatch \tMatches");
    for (int i=0; i<exprV.length;i++) 
    {
        r = new RE(exprV[i]);
	for (int j=0; j<matchV.length; j++)
	{    
	    matched = r.match(matchV[j]);
	    System.out.println(exprV[i]+"\t"+matchV[j]+"\t"+matched);
	}
    } 
  }
}

the result was

expr    match   Matches
ab{0,1} a       false    <--- must be true!
ab{0,1} aa      false    <--- must be true!
ab{0,1} aba     true
ab{0,1} abba    true
ab{1}   a       false
ab{1}   aa      false
ab{1}   aba     true
ab{1}   abba    true

I got these results with Linux and java version 1.3.1_01.
Comment 1 Vadim Gritsenko 2003-04-25 18:19:24 UTC
Fixed by patch attached to bug #19329

*** This bug has been marked as a duplicate of 19329 ***
Comment 2 Vadim Gritsenko 2003-05-02 01:10:15 UTC
Fixed by Bug #19329
Comment 3 Vadim Gritsenko 2003-07-31 23:38:16 UTC
*** Bug 22035 has been marked as a duplicate of this bug. ***