Skip to main content

validate_pattern_safety

Function validate_pattern_safety 

Source
pub fn validate_pattern_safety(pattern: &str) -> (bool, &'static str)
Expand description

Check if a pattern contains constructs that cause catastrophic backtracking in PCRE/Python re.

Rust’s regex crate uses finite automata and is inherently ReDoS-safe, but this flags patterns that would be dangerous in other engines. On match, the returned reason names the specific dangerous construct.