pub struct PyRegex { /* private fields */ }
Expand description
A wrapper for a compiled regular expression from the Python regex
library.
Implementations§
Source§impl PyRegex
impl PyRegex
Sourcepub fn new(pattern: &str) -> PyResult<Self>
pub fn new(pattern: &str) -> PyResult<Self>
Creates a new regular expression by compiling the pattern via Python’s regex.compile
.
Sourcepub fn search_match(&self, text: &str) -> PyResult<Option<PyRegexMatch>>
pub fn search_match(&self, text: &str) -> PyResult<Option<PyRegexMatch>>
Performs a search for the first match and returns a PyRegexMatch
object.
Sourcepub fn find_iter(&self, text: &str) -> PyResult<Vec<PyRegexMatch>>
pub fn find_iter(&self, text: &str) -> PyResult<Vec<PyRegexMatch>>
Returns a list of PyRegexMatch
objects from finditer()
.
pub fn is_match(&self, text: &str) -> PyResult<bool>
pub fn find_all(&self, text: &str) -> PyResult<Vec<String>>
pub fn replace(&self, text: &str, replacement: &str) -> PyResult<String>
pub fn split(&self, text: &str) -> PyResult<Vec<String>>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PyRegex
impl !RefUnwindSafe for PyRegex
impl Send for PyRegex
impl Sync for PyRegex
impl Unpin for PyRegex
impl UnwindSafe for PyRegex
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
Mutably borrows from an owned value. Read more