[−][src]Struct syntect::parsing::Regex
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.
Methods
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>>
[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]
&self,
text: &str,
begin: usize,
end: usize,
region: Option<&mut Region>
) -> bool
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]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Regex
[src]
impl<'de> Deserialize<'de> for Regex
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,