Skip to main content

RegexOptions

Struct RegexOptions 

Source
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: usize

max cached DFA states, clamped to u16::MAX (default: u16::MAX).

§lookahead_context_max: u32

max lookahead context distance (default: 800).

§unicode: UnicodeMode

Unicode coverage for \w/\d/\s and width of . / negated classes (default: UnicodeMode::Default).

§case_insensitive: bool

global 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: bool

allow whitespace and # comments in the pattern (default: false).

§hardened: bool

use hardened forward scan (default: false). slower, but prevents O(n^2) all-matches blowup on adversarial combinations.

§unbounded_size: bool

remove the default pattern size limit for very large regexes (default: false).

Implementations§

Source§

impl RegexOptions

Source

pub fn unicode(self, mode: UnicodeMode) -> Self

set Unicode coverage for \w/\d/\s and width of . / negated classes.

Source

pub fn case_insensitive(self, yes: bool) -> Self

set case-insensitive mode.

Source

pub fn dot_matches_new_line(self, yes: bool) -> Self

set dot-matches-newline mode.

Source

pub fn multiline(self, yes: bool) -> Self

^/$ match at \n (default: true), set false to make ^/$ same as \A/\z.

Source

pub fn ignore_whitespace(self, yes: bool) -> Self

set ignore-whitespace (verbose) mode.

Source

pub fn hardened(self, yes: bool) -> Self

enable hardened mode for untrusted patterns: uses only O(N·S) forward scan (~5-20x constant overhead).

Source

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.

Trait Implementations§

Source§

impl Default for RegexOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.