Class Regex
java.lang.Object
ai.attackframework.tools.burp.utils.Regex
Centralized helpers for regex compilation and flag derivation.
Keeping flag logic in one place avoids drift between UI components and utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic PatternCompile a pattern with flags derived from the provided toggles.static PatterncompileOrNull(String pattern, boolean caseSensitive, boolean multiline) Compile a pattern or returnnullif invalid.static intflags(boolean caseSensitive, boolean multiline) DerivePatternflags from UI toggles.static booleanReturns whether the supplied pattern compiles with the derived flags.
-
Method Details
-
flags
public static int flags(boolean caseSensitive, boolean multiline) DerivePatternflags from UI toggles.- Parameters:
caseSensitive- whether matching is case-sensitivemultiline- whetherPattern.MULTILINEshould be applied- Returns:
- integer bitmask for
Pattern.compile(String, int)
-
compile
Compile a pattern with flags derived from the provided toggles.- Parameters:
pattern- the regex pattern textcaseSensitive- whether the match is case-sensitivemultiline- whetherPattern.MULTILINEshould be applied- Returns:
- compiled
Pattern - Throws:
PatternSyntaxException- if the pattern is invalid
-
isValid
Returns whether the supplied pattern compiles with the derived flags.This is a convenience for UI validation paths that should not rely on exception-driven control flow while the user is typing.
- Parameters:
pattern- the pattern text (may benull)caseSensitive- whether the match is case-sensitivemultiline- whetherPattern.MULTILINEshould be applied- Returns:
trueifcompile(String, boolean, boolean)succeeds;falseotherwise
-
compileOrNull
Compile a pattern or returnnullif invalid.- Parameters:
pattern- the pattern text (may benull)caseSensitive- whether the match is case-sensitivemultiline- whetherPattern.MULTILINEshould be applied- Returns:
- compiled
Patternornullif invalid
-