>Pattern p = ac.compile("^ISIN\\s[A-Z]{12}");
>            OR
>Pattern p = ac.compile("^ISIN[\\s]{1}[A-Z]{12}");
>            OR
>Pattern p = ac.compile("^ISIN [A-Z]{12}");
>            OR
>Pattern p = ac.compile("^ISIN[\\n\\f\\r\\t]{1}[A-Z]{12}");
>            OR
>Pattern p = ac.compile("^ISIN[\\n\\f\\r\\t][A-Z]{12}");
>
>AwkMatcher am = new AwkMatcher();
>System.out.println(am.matches(str,p));
>
>The above print statement in all the above different patterns prints false.

I tested your patterns and everything seems to be fine.  The last two
obviously don't match because they don't include a space in the character
class.  Perhaps you are using an older version of the library.  I don't
recall any issues with the awk package, but there may have been a bug
that was fixed.  Here's the test program tested against version 2.0.8:

import org.apache.oro.text.regex.*;
import org.apache.oro.text.awk.*;

public class example {

  public static final String[] PATTERNS = {
    "^ISIN\\s[A-Z]{12}",
    "^ISIN[\\s]{1}[A-Z]{12}",
    "^ISIN [A-Z]{12}",
    "^ISIN[\\n\\f\\r\\t]{1}[A-Z]{12}",
    "^ISIN[\\n\\f\\r\\t][A-Z]{12}"
  };


  public final static void main(String[] args) {
    AwkCompiler compiler = new AwkCompiler();
    AwkMatcher matcher   = new AwkMatcher();


    try {
      for(int i = 0; i < PATTERNS.length; ++i) {
        Pattern pattern = compiler.compile(PATTERNS[i]);
        System.out.println(matcher.matches("ISIN AAAAAAAAAAAA", pattern));
      }
    } catch(MalformedPatternException e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
}

Here's my run:

/tmp> javac example.java
/tmp> java example
true
true
true
false
false

As I indicated, the last two fail because they lack a space in the
character class.  Hope that helps.

daniel



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to