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:
-
- ? + .
- |
- ()
- [] [^] [&&]
- ^ $
Download zip files and jar files can be found in the zip package.
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");
FastRegex use the same test cases with JDK, FastRegex currently passes every test case FastRegex has support for.