Package org.jsoup.helper
Class Regex
java.lang.Object
org.jsoup.helper.Regex
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 ClassesModifier and TypeClassDescriptionprivate static final classstatic interface -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RegexCompile 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 switch(package private) static booleanhasRe2j()matcher(CharSequence input) toString()static booleanChecks if re2j is available (on classpath) and enabled (via system property).(package private) static boolean(package private) static voidwantsRe2j(boolean use)
-
Field Details
-
hasRe2j
private static final boolean hasRe2j -
jdkPattern
-
-
Constructor Details
-
Regex
Regex(Pattern jdkPattern)
-
-
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
-
wantsRe2j
static boolean wantsRe2j() -
wantsRe2j
static void wantsRe2j(boolean use) -
hasRe2j
static boolean hasRe2j() -
matcher
-
toString
-