pub struct Regex { /* private fields */ }Expand description
A regular expression engine designed for use within the ad text editor.
This is a relatively naive implementation though it does have some optimisations and runs reasonably quickly. It is not at all designed to be robust against malicious input and it does not attempt to support full PCRE syntax or functionality.
Implementations§
Source§impl Regex
impl Regex
Sourcepub fn compile(re: impl AsRef<str>) -> Result<Self, Error>
pub fn compile(re: impl AsRef<str>) -> Result<Self, Error>
Attempt to compile the given regular expression into its optimised VM opcode form.
This method handles pre-allocation of the memory required for running the VM so that the allocation cost is paid once up front rather than on each use of the Regex.
Sourcepub fn matches<H>(&self, haystack: &H) -> boolwhere
H: Haystack,
pub fn matches<H>(&self, haystack: &H) -> boolwhere
H: Haystack,
Determine whether or not this Regex matches the Haystack without searching for the leftmost-longest match and associated submatch boundaries.
Sourcepub fn matches_from<H>(&self, haystack: &H, offset: usize) -> boolwhere
H: Haystack,
pub fn matches_from<H>(&self, haystack: &H, offset: usize) -> boolwhere
H: Haystack,
Determine whether or not this Regex matches the Haystack from the given offset without searching for the leftmost-longest match and associated submatch boundaries.
Sourcepub fn matches_between<H>(&self, haystack: &H, from: usize, to: usize) -> boolwhere
H: Haystack,
pub fn matches_between<H>(&self, haystack: &H, from: usize, to: usize) -> boolwhere
H: Haystack,
Determine whether or not this Regex matches the Haystack between the given offsets without searching for the leftmost-longest match and associated submatch boundaries.
Sourcepub fn find<H>(&self, haystack: &H) -> Option<Match>where
H: Haystack,
pub fn find<H>(&self, haystack: &H) -> Option<Match>where
H: Haystack,
Search the given Haystack for the leftmost longest match of this Regex and return the match position along with all submatches.
It is recommended that you call Haystack::try_make_contiguous before calling this method in order to speed up searching whenever this is possible.
Sourcepub fn find_from<H>(&self, haystack: &H, offset: usize) -> Option<Match>where
H: Haystack,
pub fn find_from<H>(&self, haystack: &H, offset: usize) -> Option<Match>where
H: Haystack,
Search the given Haystack for the leftmost longest match of this Regex starting from the provided byte offset rather than the beginning of the haystack, returning the match position along with all submatches.
It is recommended that you call Haystack::try_make_contiguous before calling this method in order to speed up searching whenever this is possible.
Sourcepub fn find_between<H>(
&self,
haystack: &H,
from: usize,
to: usize,
) -> Option<Match>where
H: Haystack,
pub fn find_between<H>(
&self,
haystack: &H,
from: usize,
to: usize,
) -> Option<Match>where
H: Haystack,
Search the given Haystack for the leftmost longest match of this Regex starting from
the provided byte offset rather than the beginning of the haystack, and ending before
the provided char_to, returning the match position along with all submatches.
It is recommended that you call Haystack::try_make_contiguous before calling this method in order to speed up searching whenever this is possible.
Sourcepub fn find_iter<'a, H>(&'a mut self, haystack: &'a H) -> MatchIter<'a, H>where
H: Haystack,
pub fn find_iter<'a, H>(&'a mut self, haystack: &'a H) -> MatchIter<'a, H>where
H: Haystack,
It is recommended that you call Haystack::try_make_contiguous before calling this method in order to speed up searching whenever this is possible.
Trait Implementations§
Source§impl Haystack<Regex> for Buffer
impl Haystack<Regex> for Buffer
Source§fn is_match_between(&self, re: &Regex, from: usize, to: usize) -> bool
fn is_match_between(&self, re: &Regex, from: usize, to: usize) -> bool
Source§fn captures_between(
&self,
re: &Regex,
from: usize,
to: usize,
) -> Option<RawCaptures>
fn captures_between( &self, re: &Regex, from: usize, to: usize, ) -> Option<RawCaptures>
Source§impl<R> Haystack<Regex> for CachingStream<R>where
R: Read,
impl<R> Haystack<Regex> for CachingStream<R>where
R: Read,
Source§fn is_match_between(&self, re: &Regex, from: usize, to: usize) -> bool
fn is_match_between(&self, re: &Regex, from: usize, to: usize) -> bool
Source§fn captures_between(
&self,
re: &Regex,
from: usize,
to: usize,
) -> Option<RawCaptures>
fn captures_between( &self, re: &Regex, from: usize, to: usize, ) -> Option<RawCaptures>
Source§impl Haystack<Regex> for GapBuffer
impl Haystack<Regex> for GapBuffer
Source§fn is_match_between(&self, re: &Regex, from: usize, to: usize) -> bool
fn is_match_between(&self, re: &Regex, from: usize, to: usize) -> bool
Source§fn captures_between(
&self,
re: &Regex,
from: usize,
to: usize,
) -> Option<RawCaptures>
fn captures_between( &self, re: &Regex, from: usize, to: usize, ) -> Option<RawCaptures>
Source§impl Haystack<Regex> for str
impl Haystack<Regex> for str
Source§fn is_match_between(&self, re: &Regex, from: usize, to: usize) -> bool
fn is_match_between(&self, re: &Regex, from: usize, to: usize) -> bool
Source§fn captures_between(
&self,
re: &Regex,
from: usize,
to: usize,
) -> Option<RawCaptures>
fn captures_between( &self, re: &Regex, from: usize, to: usize, ) -> Option<RawCaptures>
Source§impl RegexEngine for Regex
impl RegexEngine for Regex
Source§type CompileError = Error
type CompileError = Error
impl Eq for Regex
Auto Trait Implementations§
impl !Freeze for Regex
impl RefUnwindSafe for Regex
impl Send for Regex
impl Sync for Regex
impl Unpin for Regex
impl UnwindSafe for Regex
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.