Skip to main content

compile_bounded

Function compile_bounded 

Source
pub fn compile_bounded(pattern: &str) -> Result<Regex, RegexCompileError>
Expand description

Compile an untrusted pattern under fixed memory bounds.

The length gate is checked before the pattern reaches the regex engine, so an over-long pattern is rejected cheaply.

§Errors

Returns RegexCompileError::TooLong if pattern exceeds MAX_PATTERN_LEN bytes, or RegexCompileError::Compile if it is syntactically invalid or would exceed the compile-time memory bounds.