pub struct FuzzyRegexBuilder { /* private fields */ }Expand description
Builder for constructing a FuzzyRegex with custom configuration.
Implementations§
Source§impl FuzzyRegexBuilder
impl FuzzyRegexBuilder
Sourcepub fn case_insensitive(self, yes: bool) -> Self
pub fn case_insensitive(self, yes: bool) -> Self
Set case-insensitive matching.
Sourcepub fn verbose(self, yes: bool) -> Self
pub fn verbose(self, yes: bool) -> Self
Enable verbose mode (ignore whitespace and allow # comments).
In verbose mode:
- Whitespace is ignored (use
\sor[ ]for literal space) #starts a comment that extends to end of line
This allows formatting patterns for readability:
(?x)
[A-Z][a-z]+ # First name
\s+ # Whitespace
[A-Z][a-z]+ # Last nameSourcepub fn dot_all(self, yes: bool) -> Self
pub fn dot_all(self, yes: bool) -> Self
Enable dot-all mode (. matches newlines).
By default, . matches any character except newlines.
When enabled, . matches any character including \n.
Sourcepub fn multi_line(self, yes: bool) -> Self
pub fn multi_line(self, yes: bool) -> Self
Enable multi-line mode (^ and $ match at line boundaries).
By default, ^ matches only at the start of text and $ only at the end.
When enabled:
^also matches after each newline$also matches before each newline
Sourcepub fn ungreedy(self, yes: bool) -> Self
pub fn ungreedy(self, yes: bool) -> Self
Enable ungreedy mode (invert default greediness of quantifiers).
When enabled:
*,+,?become non-greedy (match as little as possible)*?,+?,??become greedy (match as much as possible)
This is equivalent to the (?U) inline flag.
Sourcepub fn global(self, yes: bool) -> Self
pub fn global(self, yes: bool) -> Self
Enable global mode (find all matches).
When enabled, use find_iter() to get all matches.
When disabled (default), stops at first valid match (faster).
This is equivalent to the (?g) inline flag.
Sourcepub fn greedy_first(self, yes: bool) -> Self
pub fn greedy_first(self, yes: bool) -> Self
Enable greedy first-match mode (similar to mrab-regex behavior).
When enabled, searches position by position and returns the first match found. This is faster than the default best-match behavior when matches exist early in the text, but may not find the optimal match.
Default behavior (greedy_first=false): searches all positions to find best match.
Greedy first (greedy_first=true): stops at first match found.
Sourcepub fn unicode(self, yes: bool) -> Self
pub fn unicode(self, yes: bool) -> Self
Enable Unicode mode for character classes.
When enabled:
\wmatches Unicode word characters (not just ASCII[a-zA-Z0-9_])\dmatches Unicode digits\smatches Unicode whitespace
This is equivalent to the (?u) inline flag.
Sourcepub fn similarity(self, threshold: f32) -> Self
pub fn similarity(self, threshold: f32) -> Self
Set the similarity threshold (0.0 - 1.0).
Matches with similarity below this threshold are rejected.
Sourcepub fn edits(self, count: u8) -> Self
pub fn edits(self, count: u8) -> Self
Set the default number of edits allowed for fuzzy matching.
This applies to literals without explicit fuzziness markers.
Sourcepub fn fuzzy(self, limits: FuzzyLimits) -> Self
pub fn fuzzy(self, limits: FuzzyLimits) -> Self
Set detailed fuzzy limits for default matching.
Sourcepub fn penalties(self, penalties: FuzzyPenalties) -> Self
pub fn penalties(self, penalties: FuzzyPenalties) -> Self
Set edit operation penalties.
Sourcepub fn max_threads(self, max: usize) -> Self
pub fn max_threads(self, max: usize) -> Self
Set the maximum number of threads for NFA simulation.
Higher values allow more complex patterns but use more memory.
Sourcepub fn partial(self, yes: bool) -> Self
pub fn partial(self, yes: bool) -> Self
Enable partial matching.
When enabled, matches that reach the end of the text are considered
successful even if they haven’t completed. The Match::partial() method
can be used to check if a match is partial.
This is useful for streaming input or when the text may be truncated.
Sourcepub fn timeout(self, duration: Duration) -> Self
pub fn timeout(self, duration: Duration) -> Self
Set a timeout for matching operations.
If a match operation takes longer than the timeout, it will be cancelled. The default is no timeout.
Note: Timeout is checked at certain checkpoints during matching, so it’s not precise. The actual time may exceed the timeout slightly.
Sourcepub fn build(self) -> Result<FuzzyRegex>
pub fn build(self) -> Result<FuzzyRegex>
Trait Implementations§
Source§impl Clone for FuzzyRegexBuilder
impl Clone for FuzzyRegexBuilder
Source§fn clone(&self) -> FuzzyRegexBuilder
fn clone(&self) -> FuzzyRegexBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more