pub struct Regex { /* private fields */ }Expand description
compiled regex backed by a lazy DFA.
uses a Mutex for mutable DFA state.
Implementations§
Source§impl Regex
impl Regex
Sourcepub fn new(pattern: &str) -> Result<Regex, Error>
pub fn new(pattern: &str) -> Result<Regex, Error>
compile a pattern with default options.
let re = resharp::Regex::new(r"\b\w+\b").unwrap();Sourcepub fn with_options(pattern: &str, opts: EngineOptions) -> Result<Regex, Error>
pub fn with_options(pattern: &str, opts: EngineOptions) -> Result<Regex, Error>
compile a pattern with custom EngineOptions.
use resharp::{Regex, EngineOptions};
let re = Regex::with_options(
r"hello",
EngineOptions::default().case_insensitive(true),
).unwrap();
assert!(re.is_match(b"HELLO").unwrap());Sourcepub fn from_node(
b: RegexBuilder,
node: NodeId,
opts: EngineOptions,
) -> Result<Regex, Error>
pub fn from_node( b: RegexBuilder, node: NodeId, opts: EngineOptions, ) -> Result<Regex, Error>
build from a pre-constructed AST node.
Sourcepub fn is_hardened(&self) -> bool
pub fn is_hardened(&self) -> bool
whether hardened linear-scan mode is enabled
Sourcepub fn find_all(&self, input: &[u8]) -> Result<Vec<Match>, Error>
pub fn find_all(&self, input: &[u8]) -> Result<Vec<Match>, Error>
all non-overlapping leftmost-first matches as [start, end) byte ranges.
let re = resharp::Regex::new(r"\d+").unwrap();
let m = re.find_all(b"abc 123 def 456").unwrap();
assert_eq!(m.len(), 2);
assert_eq!((m[0].start, m[0].end), (4, 7));Auto Trait Implementations§
impl !Freeze for Regex
impl RefUnwindSafe for Regex
impl Send for Regex
impl Sync for Regex
impl Unpin for Regex
impl UnsafeUnpin 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