public final class RegexUtils extends Object
Design Decision:
See also: OWASP ReDoS
| Modifier and Type | Method and Description |
|---|---|
static boolean |
find(Pattern pattern,
String input,
long timeoutMs)
|
static boolean |
matches(Pattern pattern,
String input,
long timeoutMs)
|
static String |
replaceAll(String input,
Map<Pattern,String> replacements,
long timeoutMs)
Executes a
matcher().replaceAll(String) operation with timeout protection. |
public static String replaceAll(String input, Map<Pattern,String> replacements, long timeoutMs) throws InterruptedException, ExecutionException, TimeoutException
matcher().replaceAll(String) operation with timeout protection.
See class-level JavaDoc for details on ReDoS protection.input - The input stringreplacements - The regex operation to performtimeoutMs - The timeout in millisecondsInterruptedException - if the current thread is interruptedExecutionException - if the operation throws an exceptionTimeoutException - if the operation exceeds the specified timeoutpublic static boolean find(Pattern pattern, String input, long timeoutMs) throws InterruptedException, ExecutionException, TimeoutException
matcher().find() operation with timeout protection.
See class-level JavaDoc for details on ReDoS protection.pattern - The pattern to matchinput - The input stringtimeoutMs - The timeout in millisecondsInterruptedException - if the current thread is interruptedExecutionException - if the operation throws an exceptionTimeoutException - if the operation exceeds the specified timeoutpublic static boolean matches(Pattern pattern, String input, long timeoutMs) throws InterruptedException, ExecutionException, TimeoutException
matcher().matches() operation with timeout protection.
See class-level JavaDoc for details on ReDoS protection.pattern - The pattern to matchinput - The input stringtimeoutMs - The timeout in millisecondsInterruptedException - if the current thread is interruptedExecutionException - if the operation throws an exceptionTimeoutException - if the operation exceeds the specified timeoutCopyright © 2016–2025. All rights reserved.