Did anyone come across Java version of Google's regular expression library RE2 or a java library with similar capabilities and good performance? The performance requirement is linear time with regard to the length of regular expression and the input text length.
Most regular expression implementation use a backtracking algorithm to match the input text and hence are exponential on some simple regular expressions like (.*).(.*).(.*).(.*)
. RE2 is a library from google that solves this problem by using an algorithm that varies linearly with input size using the concepts of Automata theory. The questioner wants to know whether there exists libraries for Java that are based on this algorithm.
Regular Expressions or Regex (in short) in Java is an API for defining String patterns that can be used for searching, manipulating, and editing a string in Java. Email validation and passwords are a few areas of strings where Regex is widely used to define the constraints. Regular Expressions are provided under java.
RE2/J: linear time regular expression matching in Java RE2 is a regular expression engine that runs in time linear in the size of the input. RE2/J is a port of C++ library RE2 to pure Java.
Google today released a pure-Java port of Go's RE2 implementation. You can find it here:
https://github.com/google/re2j
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With