Skip to main content

MAX_REGEX_DEPTH

Constant MAX_REGEX_DEPTH 

Source
pub const MAX_REGEX_DEPTH: usize = 256;
Expand description

How deep groups and character classes may nest in one pattern.

Oniguruma’s own default limit is far higher (4096); this one is low enough that every engine that loads TextMate grammars handles it, and far above what a hand-written or generated pattern needs.

§Examples

use textmate_lang::{MAX_REGEX_DEPTH, validate_regex};

let deep = "(".repeat(MAX_REGEX_DEPTH + 1) + &")".repeat(MAX_REGEX_DEPTH + 1);
assert!(validate_regex(&deep).is_err());