Package org.jsoup.helper
Class Regex
java.lang.Object
org.jsoup.helper.Regex
public class Regex extends Object
A regular expression abstraction. Allows jsoup to optionally use the re2j regular expression engine (linear time) instead of the JDK's backtracking regex implementation.
If the com.google.re2j library is found on the classpath, by default it will be used. You can override this by setting -Djsoup.useRe2j=false to explicitly disable, and use the JDK regex engine.
(Currently this a simplified implementation for jsoup's specific use; can extend as required.)
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic Regexcompile(String regex) Compile a regex, using re2j if enabled and available; otherwise JDK regex.static RegexfromPattern(Pattern pattern) Wraps an existing JDK Pattern (for API compat); doesn't switchmatcher(CharSequence input) StringtoString()static booleanChecks if re2j is available (on classpath) and enabled (via system property).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Method Details
-
compile
Compile a regex, using re2j if enabled and available; otherwise JDK regex.- Parameters:
-
regex- the regex to compile - Returns:
- the compiled regex
- Throws:
-
ValidationException- if the regex is invalid
-
fromPattern
Wraps an existing JDK Pattern (for API compat); doesn't switch -
usingRe2j
public static boolean usingRe2j()Checks if re2j is available (on classpath) and enabled (via system property).- Returns:
- true if re2j is available and enabled
-
matcher
-
toString
public String toString()- Overrides:
-
toStringin classObject
-