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 mallicious input and it does not attempt to support full PCRE syntax or functionality.
Implementations§
Source§impl Regex
impl Regex
Sourcepub fn compile(re: &str) -> Result<Self, Error>
pub fn compile(re: &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 compile_reverse(re: &str) -> Result<Self, Error>
pub fn compile_reverse(re: &str) -> Result<Self, Error>
Attempt to compile the given regular expression into its reversed optimised VM opcode form. This is used for searching backwards through an input stream.
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 match_str(&mut self, input: &str) -> Option<Match>
pub fn match_str(&mut self, input: &str) -> Option<Match>
Attempt to match this Regex against a given &str
input, returning the position
of the match and all submatches if successful.
Sourcepub fn match_str_all<'a, 'b>(
&'a mut self,
input: &'b str,
) -> MatchIter<'a, &'b str> ⓘ
pub fn match_str_all<'a, 'b>( &'a mut self, input: &'b str, ) -> MatchIter<'a, &'b str> ⓘ
Iterate over all non-overlapping matches of this Regex for a given &str
input.
Sourcepub fn match_buffer_all<'a, 'b>(
&'a mut self,
b: &'b Buffer,
) -> MatchIter<'a, &'b GapBuffer> ⓘ
pub fn match_buffer_all<'a, 'b>( &'a mut self, b: &'b Buffer, ) -> MatchIter<'a, &'b GapBuffer> ⓘ
Iterate over all non-overlapping matches of this Regex for a given Buffer
input.
Sourcepub fn match_iter<I>(&mut self, input: &mut I, sp: usize) -> Option<Match>
pub fn match_iter<I>(&mut self, input: &mut I, sp: usize) -> Option<Match>
Attempt to match this Regex against an arbitrary iterator input, returning the position of the match and all submatches if successful.
Sourcepub fn matches_str(&mut self, input: &str) -> bool
pub fn matches_str(&mut self, input: &str) -> bool
Determine whether or not this Regex matches the input &str
without searching for
the leftmost-longest match and associated submatch boundaries.
Trait Implementations§
impl Eq for Regex
impl StructuralPartialEq 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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.