pub struct BinRegex {
pub n_groups: usize,
/* private fields */
}
Expand description
A compiled variation of regular expressions intended for searching binary data. A
BinRegex
can be used to search binary data for patterns
Fields§
§n_groups: usize
Implementations§
source§impl BinRegex
impl BinRegex
sourcepub fn new(pattern: &str) -> Result<BinRegex, String>
pub fn new(pattern: &str) -> Result<BinRegex, String>
Compiles a binary regular expression. Once compiled, this object can be used repeatedly to search input buffers.
sourcepub fn find<'a, T>(&'a self, input: &'a T) -> Option<BinMatch<'_, T>>where
&'a T: BitIndexable,
T: BitIndexable,
pub fn find<'a, T>(&'a self, input: &'a T) -> Option<BinMatch<'_, T>>where &'a T: BitIndexable, T: BitIndexable,
Searches for the first match in the input given, and if found returns a BinMatch
object corresponding to the match. If no match is found, returns None
.
Examples
use bitutils2::{BinRegex, BitIndex};
let input = vec![0x00, 0x0a, 0xbc, 0x00, 0x00, 0x00, 0xff, 0x00];
let re1 = BinRegex::new("ABC_{8,}''").unwrap();
let m1 = re1.find(&input).unwrap();
assert_eq!(m1.span(), (BitIndex::new(1, 4), BitIndex::new(6, 2)));
let re2 = BinRegex::new("ABC_{8,}'_").unwrap();
assert_eq!(re2.find(&input), None);
sourcepub fn find_iter<'a, T>(&'a self, input: &'a T) -> BinMatches<'a, T> ⓘwhere
&'a T: BitIndexable,
T: BitIndexable,
pub fn find_iter<'a, T>(&'a self, input: &'a T) -> BinMatches<'a, T> ⓘwhere &'a T: BitIndexable, T: BitIndexable,
Returns an iterator that yields successive non-overlapping matches in the input buffer.
pub fn match_length<'a, T>(&'a self, input: &'a T) -> Option<BitIndex>where &'a T: BitIndexable,
pub fn captures<'a, T>(&'a self, input: &'a T) -> Option<BinCaptures<'_, T>>where &'a T: BitIndexable, T: BitIndexable,
Auto Trait Implementations§
impl RefUnwindSafe for BinRegex
impl !Send for BinRegex
impl !Sync for BinRegex
impl Unpin for BinRegex
impl UnwindSafe for BinRegex
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