pub struct RegexOptions {
pub max_dfa_capacity: usize,
pub lookahead_context_max: u32,
pub unicode: UnicodeMode,
pub case_insensitive: bool,
pub dot_matches_new_line: bool,
pub multiline: bool,
pub ignore_whitespace: bool,
pub hardened: bool,
pub unbounded_size: bool,
}Expand description
Regex configuration, passed to Regex::with_options.
Fields§
§max_dfa_capacity: usizemax cached DFA states, clamped to u16::MAX (default: u16::MAX).
lookahead_context_max: u32max lookahead context distance (default: 800).
unicode: UnicodeModeUnicode coverage for \w/\d/\s and width of . / negated classes
(default: UnicodeMode::Default).
case_insensitive: boolglobal case-insensitive matching (default: false).
dot_matches_new_line: bool. matches \n (default: false). _ always matches any byte.
multiline: bool^ and $ match at line boundaries (\n) in addition to text
boundaries (default: true). Disable with (?-m) inline or this flag.
ignore_whitespace: boolallow whitespace and # comments in the pattern (default: false).
hardened: booluse hardened forward scan (default: false). slower, but prevents O(n^2) all-matches blowup on adversarial combinations.
unbounded_size: boolremove the default pattern size limit for very large regexes (default: false).
Implementations§
Source§impl RegexOptions
impl RegexOptions
Sourcepub fn unicode(self, mode: UnicodeMode) -> Self
pub fn unicode(self, mode: UnicodeMode) -> Self
set Unicode coverage for \w/\d/\s and width of . / negated classes.
Sourcepub fn case_insensitive(self, yes: bool) -> Self
pub fn case_insensitive(self, yes: bool) -> Self
set case-insensitive mode.
Sourcepub fn dot_matches_new_line(self, yes: bool) -> Self
pub fn dot_matches_new_line(self, yes: bool) -> Self
set dot-matches-newline mode.
Sourcepub fn multiline(self, yes: bool) -> Self
pub fn multiline(self, yes: bool) -> Self
^/$ match at \n (default: true), set false to make ^/$ same as \A/\z.
Sourcepub fn ignore_whitespace(self, yes: bool) -> Self
pub fn ignore_whitespace(self, yes: bool) -> Self
set ignore-whitespace (verbose) mode.
Sourcepub fn hardened(self, yes: bool) -> Self
pub fn hardened(self, yes: bool) -> Self
enable hardened mode for untrusted patterns: uses only O(N·S) forward scan (~5-20x constant overhead).
Sourcepub fn unbounded_size(self, yes: bool) -> Self
pub fn unbounded_size(self, yes: bool) -> Self
disable parser and algebra size caps. the defaults are generous; if you hit them, splitting the pattern into several smaller regexes is almost always the better fix than raising the limit.