regex package...

Discussion in 'Java' started by One, May 19, 2008.

  1. One

    One Guest

    Has anyone used this this DFA based package
    http://www.brics.dk/~amoeller/automaton/

    I have a question about it:

    public class test
    {
    public static void main (String[] args)
    {
    int count = 0;
    String s = "abdccabcdc";
    String s2 = "ab(c|d)*";

    // .brics package
    dk.brics.automaton.RegExp r = new dk.brics.automaton.RegExp (s2);
    dk.brics.automaton.Automaton a = r.toAutomaton();

    //java regex package
    java.util.regex.Matcher m =
    java.util.regex.Pattern.compile(s2).matcher(s);

    System.out.println("Match: " +a.run(s)); // this prints false? why?

    while (m.find()) count++;

    // java regex prints the right result 2
    System.out.println("Match: " + " " + count);
    }
    }

    Can anyone post an example that will get brics.automaton to print 2 in
    this example, like java.util.regex does.
     
    One, May 19, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Parvinder
    Replies:
    6
    Views:
    750
    Thomas G. Marshall
    Feb 27, 2005
  2. Dave
    Replies:
    2
    Views:
    473
  3. George P
    Replies:
    3
    Views:
    687
    Alex Martelli
    Sep 11, 2004
  4. David Pratt
    Replies:
    4
    Views:
    336
    David Pratt
    May 13, 2006
  5. Replies:
    3
    Views:
    773
    Reedick, Andrew
    Jul 1, 2008
Loading...

Share This Page