pub struct Regex(/* private fields */);
Implementations§
Source§impl Regex
impl Regex
pub fn new(s: &str) -> Regex
Sourcepub fn is_match(&self, s: &str) -> bool
pub fn is_match(&self, s: &str) -> bool
Returns true if and only if the regex matches the string given.
§Example
let pineapple = Regex::new(r"pine
apple");
assert!(pineapple.is_match("I bought a pineapple."));
// Digit or `a`. `-` is set difference.
let char_class = Regex::new(r"<[ 0 .. 9 a .. z] - [ b .. z ]>");
assert!(char_class.is_match("3"));
assert!(char_class.is_match("a"));
assert!(!char_class.is_match("b"));
}
Trait Implementations§
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
Mutably borrows from an owned value. Read more