Class SafeRegex

java.lang.Object
org.jline.utils.SafeRegex

public final class SafeRegex extends Object
Regex utilities that guard against catastrophic backtracking (ReDoS).

Java's java.util.regex engine uses backtracking, so patterns with nested quantifiers (e.g. (a+)+b) can take exponential time on non-matching input. This class wraps input in a CharSequence that enforces a wall-clock deadline, throwing RegexTimeoutException if matching takes too long.

Usage: