pub struct RegexBuilder { /* private fields */ }Expand description
Configuration options for regex compilation.
Implementations§
Source§impl RegexBuilder
impl RegexBuilder
Sourcepub fn jit(self, enabled: bool) -> Self
pub fn jit(self, enabled: bool) -> Self
Enables or disables JIT compilation.
When enabled, the regex will be compiled to native machine code for maximum performance. This is ideal for patterns that will be matched many times (e.g., tokenization).
JIT compilation has higher upfront cost but faster matching.
Only available on x86-64 with the jit feature enabled.
§Example
use regexr::RegexBuilder;
let re = RegexBuilder::new(r"\w+")
.jit(true)
.build()
.unwrap();
assert!(re.is_match("hello"));Sourcepub fn optimize_prefixes(self, enabled: bool) -> Self
pub fn optimize_prefixes(self, enabled: bool) -> Self
Enables or disables prefix optimization for large alternations.
When enabled, large alternations of literals (like (token1|token2|...|tokenN))
will be optimized by merging common prefixes into a trie structure.
This reduces the number of active NFA threads from O(vocabulary_size) to O(token_length).
This is critical for tokenizer-style patterns with many literal alternatives.
§Example
use regexr::RegexBuilder;
// Pattern with many tokens sharing common prefixes
let re = RegexBuilder::new(r"(the|that|them|they|this)")
.optimize_prefixes(true)
.build()
.unwrap();
assert!(re.is_match("the"));Trait Implementations§
Source§impl Clone for RegexBuilder
impl Clone for RegexBuilder
Source§fn clone(&self) -> RegexBuilder
fn clone(&self) -> RegexBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RegexBuilder
impl Debug for RegexBuilder
Source§impl Default for RegexBuilder
impl Default for RegexBuilder
Source§fn default() -> RegexBuilder
fn default() -> RegexBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RegexBuilder
impl RefUnwindSafe for RegexBuilder
impl Send for RegexBuilder
impl Sync for RegexBuilder
impl Unpin for RegexBuilder
impl UnwindSafe for RegexBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more