Module bin_regex

Module bin_regex 

Source
Expand description

Provides routines for searching binary data structures (implementing BitIndexable) for specified patterns

§Syntax

§Basic Matches

 _        => Matches single 0 bit
 '        => Matches single 1 bit
 .        => Matches any single bit
 !        => Matches any byte
 0-f      => Matches corresponding nibble (case insensitive)

§Achors

 :        => Matches byte boundary
 ;        => Matches nibble boundary

§Repetitions

 *        => Causes RE to match zero or more repetitions of the preceding group (greedy)
 +        => Causes RE to match one or more repetitions of the preceding group (greedy)
 ?        => Causes RE to match zero or one repetitions of the preceding group (greedy)
 {n}      => Causes RE to match exactly n repetitions of the preceding group
 {n,}     => Causes RE to match n or more repetitions of the preceding group (greedy)
 {n,m}    => Causes RE to match between n and m repetitions of the preceding group (greedy)
 *?       => Causes RE to match zero or more repetitions of the preceding group (lazy)
 +?       => Causes RE to match one or more repetitions of the preceding group (lazy)
 ??       => Causes RE to match zero or one repetitions of the preceding group (lazy)
 {n}?     => Same as {n}
 {n,}?    => Causes RE to match n or more repetitions of the preceding group (lazy)
 {n,m}?   => Causes RE to match between n and m repetitions of the preceding group (lazy)

§Groups

 (exp)    => Numbered capture group
 (?exp) => Named (also numbered) capture group
 (?:exp)  => Non-capturing group

§Character Classes

 [a8:xyzA-Z3-9]    => 8-bit ASCII
 [u8:1,2,3,4..10]  => 8-bit unsigned integer
 [i8:1,2,3,4..10]  => 8-bit two's compliment integer
 [o8:1,2,3,4..10]  => 8-bit one's compliment integer
 [s8:1,2,3,4..10]  => 8-bit sign-magnitude integer
 [n8:1,2,3,4..10]  => 8-bit negabinary integer
 [f16:1,2,3,4..10]  => 16-bit floating point (IEEE-754 Half)
 [f32:1,2,3,4..10]  => 32-bit floating point (IEEE-754 Single)
 [f64:1,2,3,4..10]  => 64-bit floating point (IEEE-754 Double)
 [f128:1,2,3,4..10]  => 128-bit floating point (IEEE-754 Quadruple)

Matches any set of n bits that is listed in the class expression when interpreted according to the character class flag.

a: Values listed in the class expression are interpreted as ASCII u: Values listed in the class expression are interpreted as unsigned integers

§Compositions

 x|y      => Matches x or y
 xy       => Matches x followed by y

Structs§

BinCaptures
Represents the capture groups from a single match
BinMatch
Structure to contain a single BinRegex match.
BinMatches
Iterator that yields successive non-overlapping matches of the provided input. There is no public constructor for this structure, instead users must use BinRegex.find_iter.
BinRegex
A compiled variation of regular expressions intended for searching binary data. A BinRegex can be used to search binary data for patterns