[][src]Struct syntect::parsing::Regex

pub struct Regex { /* fields omitted */ }

An abstraction for regex patterns.

  • Allows swapping out the regex implementation because it's only in this module.
  • Makes regexes serializable and deserializable using just the pattern string.
  • Lazily compiles regexes on first use to improve initialization time.

Implementations

impl Regex[src]

pub fn new(regex_str: String) -> Self[src]

Create a new regex from the pattern string.

Note that the regex compilation happens on first use, which is why this method does not return a result.

pub fn try_compile(regex_str: &str) -> Option<Box<dyn Error + Send>>[src]

Check whether the pattern compiles as a valid regex or not.

pub fn regex_str(&self) -> &str[src]

Return the regex pattern.

pub fn is_match(&self, text: &str) -> bool[src]

Check if the regex matches the given text.

pub fn search(
    &self,
    text: &str,
    begin: usize,
    end: usize,
    region: Option<&mut Region>
) -> bool
[src]

Search for the pattern in the given text from begin/end positions.

If a region is passed, it is used for storing match group positions. The argument allows the Region to be reused between searches, which makes a significant performance difference.

Trait Implementations

impl Clone for Regex[src]

impl Debug for Regex[src]

impl<'de> Deserialize<'de> for Regex[src]

impl Eq for Regex[src]

impl PartialEq<Regex> for Regex[src]

impl Serialize for Regex[src]

Auto Trait Implementations

impl !RefUnwindSafe for Regex

impl Send for Regex

impl Sync for Regex

impl Unpin for Regex

impl UnwindSafe for Regex

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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.