regex package...

O

One

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top