[][src]Struct grex::RegExpBuilder

pub struct RegExpBuilder { /* fields omitted */ }

This struct builds regular expressions from user-provided test cases.

Methods

impl RegExpBuilder[src]

pub fn from<T: Clone + Into<String>>(test_cases: &[T]) -> Self[src]

Specifies the test cases to build the regular expression from.

The test cases need not be sorted because RegExpBuilder sorts them internally.

⚠ Panics if test_cases is empty.

pub fn from_file<T: Into<PathBuf>>(file_path: T) -> Self[src]

Specifies a text file containing test cases to build the regular expression from.

The test cases need not be sorted because RegExpBuilder sorts them internally.

Each test case needs to be on a separate line. Lines may be ended with either a newline (\n) or a carriage return with a line feed (\r\n). The final line ending is optional.

⚠ Panics if:

  • the file cannot be found
  • the file's encoding is not valid UTF-8 data
  • the file cannot be opened because of conflicting permissions

pub fn with_conversion_of(&mut self, features: &[Feature]) -> &mut Self[src]

Tells RegExpBuilder which conversions should be performed during regular expression generation. The available conversion features are listed in the Feature enum.

⚠ Panics if features is empty.

pub fn with_minimum_repetitions(&mut self, quantity: u32) -> &mut Self[src]

Specifies the minimum quantity of substring repetitions to be converted if Feature::Repetition is set as one of the features in method with_conversion_of.

If the quantity is not explicitly set with this method, a default value of 1 will be used.

⚠ Panics if quantity is zero.

pub fn with_minimum_substring_length(&mut self, length: u32) -> &mut Self[src]

Specifies the minimum length a repeated substring must have in order to be converted if Feature::Repetition is set as one of the features in method with_conversion_of.

If the length is not explicitly set with this method, a default value of 1 will be used.

⚠ Panics if length is zero.

pub fn with_escaping_of_non_ascii_chars(
    &mut self,
    use_surrogate_pairs: bool
) -> &mut Self
[src]

Tells RegExpBuilder to convert non-ASCII characters to unicode escape sequences. The parameter use_surrogate_pairs specifies whether to convert astral code planes (range U+010000 to U+10FFFF) to surrogate pairs.

pub fn with_syntax_highlighting(&mut self) -> &mut Self[src]

Tells RegExpBuilder to provide syntax highlighting for the resulting regular expression.

⚠ This method may only be used if the resulting regular expression is meant to be printed to the console. The regex string representation returned from enabling this setting cannot be fed into the regex crate.

pub fn build(&mut self) -> String[src]

Builds the actual regular expression using the previously given settings. Every generated regular expression is surrounded by the anchors ^ and $ so that substrings not being part of the test cases are not matched accidentally.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.