/FastRegex

A regular expression engine written in Java with NFA theory, weaker but faster than JDK

Primary LanguageJavaMIT LicenseMIT

FastRegex

FastRegex is a regular expression engine written in Java, it is faster than JDK in most cases. It works by compiling regular expressions to NFA and use NFA to match string candidates. General ideas and performance indices can be found in this post.

FastRegex has support for most regular expression features:

    • ? + .
  • |
  • ()
  • [] [^] [&&]
  • ^ $

How to get

Download zip files and jar files can be found in the zip package.

How to use

FastRegex is easy to use, you just need to get a compiled Pattern object with a legal regular expression, then you can match strings with it everywhere:)

//This regex is supposed to be matched
Pattern pattern2=Pattern.compile("^z+[1-5&&8940[3]]*(ab)(cd*)z+$");
System.out.println(pattern2.match("zzz34abczzz"));

//If this pattern is used frequently, you can use dfa match to efficiently improve the performance
boolean ans=pattern2.dfaMatch("zzzzzabczzz");

Test

FastRegex use the same test cases with JDK, FastRegex currently passes every test case FastRegex has support for.

Both Junit test classes and test cases files can be found in the tests package. License

MIT