BitVecRegexMatch
Description
Simple regex-style pattern matching for bitvectors. Supports basic patterns: ‘*’ (any sequence), ‘?’ (0 or 1), ‘[01]’ (literal).
Parameters
| Name | Direction | Description |
|---|---|---|
bv |
in | Bitvector to match against |
pattern |
in | Pattern string using regex syntax |
Usage example (from documentation)
bool matches = BitVecRegexMatch(&data, "10*01"); // 10 followed by any bits, then 01
Success
true if bitvector matches the regex pattern
Failure
false on a malformed pattern string or when no match is found.
Usage example (Cross-references)
Usage examples (Cross-references)
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecRegexMatch basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
// Test simple substring match
result = result && BitVecRegexMatch(&source, "101");
result = result && !BitVecRegexMatch(&source, "111"); // Test simple substring match
result = result && BitVecRegexMatch(&source, "101");
result = result && !BitVecRegexMatch(&source, "111");
BitVecDeinit(&source);
bool test_bitvec_regex_match_null_source(void) {
WriteFmt("Testing BitVecRegexMatch(NULL, pattern) - should fatal\n");
BitVecRegexMatch(NULL, "101");
return true; bool test_bitvec_regex_match_null_source(void) {
WriteFmt("Testing BitVecRegexMatch(NULL, pattern) - should fatal\n");
BitVecRegexMatch(NULL, "101");
return true;
} DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecRegexMatch(source, NULL) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true); BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecRegexMatch(&source, (Zstr)NULL);
BitVecDeinit(&source);
DefaultAllocatorDeinit(&alloc);
Last updated on