Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DFA Based Regular Expression Engines for Java with Capture

Tags:

java

regex

dfa

Are there any (free) regular expression engines for Java, that can compile a regular expression to a DFA, and do group capturing while matching the DFA ?

I've found dk.brics.automaton and jrexx, which both compile to DFA, but neither seems to be able to do group capture. While the other engines I've found seem to compile to NFA.

like image 441
Sami Avatar asked Dec 26 '09 18:12

Sami


2 Answers

try this one (probably not DFA but faster than java.util) http://jregex.sourceforge.net/gstarted-advanced.html#ngroups, or this one: http://userguide.icu-project.org

according to that test: http://tusker.org/regex/regex_benchmark.html, both are fast (we all know that the benchmarks only tests what the creator of the benchmark wanted to test).

When I needed really fast DFA regex I have spawned a process that used grep ;-) (For a 6GB log file it cut my times from 10minutes to a few seconds).

like image 119
bartosz.r Avatar answered Oct 21 '22 02:10

bartosz.r


I recently wrote one: tree-regex.

like image 23
nes1983 Avatar answered Oct 21 '22 02:10

nes1983