spinoso_regexp

Struct Utf8

Source
pub struct Utf8 { /* private fields */ }

Implementations§

Source§

impl Utf8

Source

pub fn with_literal_derived_encoding( source: Source, config: Config, encoding: Encoding, ) -> Result<Self, Error>

Construct a Regexp with a UTF-8 regex backend.

The constructed regexp is Unicode aware. All character classes used in patterns other than POSIX character classes support all of Unicode.

Utf8 regexps require their patterns and haystacks to be valid UTF-8.

§Examples
let pattern = br"[[:alpha:]]\d+ \d+";
let source = Source::with_pattern_and_options(pattern.to_vec(), Options::default());
let config = Config::from(&source);
let regexp = Utf8::with_literal_derived_encoding(source, config, Encoding::None)?;
assert!(regexp.is_match("a123 १०೩೬".as_bytes(), None)?);
§Errors

If the pattern in the given source is not valid UTF-8, an ArgumentError is returned. If the given source pattern fails to parse, either a SyntaxError or RegexpError is returned depending on the source Options.

Source

pub fn captures<'a>( &self, haystack: &'a [u8], ) -> Result<Option<Captures<'a>>, Error>

§Errors

If the given haystack is not valid UTF-8, an error is returned.

Source

pub fn capture_indices_for_name<'a, 'b>( &'a self, name: &'b [u8], ) -> CaptureIndices<'a, 'b>

Source

pub fn captures_len(&self) -> usize

Returns the number of captures.

Source

pub fn capture_count_for_haystack( &self, haystack: &[u8], ) -> Result<usize, ArgumentError>

The number of captures for a match of haystack against this regexp.

Captures represents a group of captured strings for a single match.

If there is a match, the returned value is always greater than 0; the 0th capture always corresponds to the entire match.

§Errors

If the given haystack is not valid UTF-8, an error is returned.

Source

pub fn entire_match<'a>( &self, haystack: &'a [u8], ) -> Result<Option<&'a [u8]>, Error>

Return the 0th capture group if haystack is matched by this regexp.

The 0th capture always corresponds to the entire match.

§Errors

If the given haystack is not valid UTF-8, an error is returned.

Source

pub fn named_captures(&self) -> NamedCaptures

Returns a hash representing information about the named captures of this Regexp.

A key of the hash is a name of the named captures. A value of the hash is an array which is list of indexes of corresponding named captures.

Source

pub fn named_captures_for_haystack( &self, haystack: &[u8], ) -> Result<Option<NamedCapturesForHaystack>, Error>

§Errors

If the given haystack is not valid UTF-8, an error is returned.

Source

pub fn names(&self) -> Vec<Vec<u8>>

Source

pub fn pos( &self, haystack: &[u8], at: usize, ) -> Result<Option<(usize, usize)>, Error>

§Errors

If the given haystack is not valid UTF-8, an error is returned.

Source

pub fn is_match(&self, haystack: &[u8], pos: Option<i64>) -> Result<bool, Error>

Check whether this regexp matches the given haystack starting at an offset.

If the given offset is negative, it counts backward from the end of the haystack.

§Errors

If the given haystack is not valid UTF-8, an error is returned.

Source

pub fn debug(&self) -> Debug<'_>

Source

pub fn is_literal(&self) -> bool

Source

pub fn source(&self) -> &Source

Source

pub fn config(&self) -> &Config

Source

pub fn encoding(&self) -> Encoding

Source

pub fn string(&self) -> &[u8]

Trait Implementations§

Source§

impl Clone for Utf8

Source§

fn clone(&self) -> Utf8

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Utf8

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Utf8

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Utf8

§

impl RefUnwindSafe for Utf8

§

impl Send for Utf8

§

impl Sync for Utf8

§

impl Unpin for Utf8

§

impl UnwindSafe for Utf8

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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.