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 Classes -
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 switchmatcher(CharSequence input) toString()static booleanChecks if re2j is available (on classpath) and enabled (via system property).
-
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
Checks if re2j is available (on classpath) and enabled (via system property).- Returns:
- true if re2j is available and enabled
-
matcher
-
toString
-