BitVecRegexMatch
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
Returns
true if bitvector matches the regex pattern
Usage example (Cross-references)
Usage examples (Cross-references)
- In
BitVec.c:1585:
}
bool BitVecRegexMatch(BitVec *bv, const char *pattern) {
ValidateBitVec(bv);
if (!pattern) {
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;
}
bool test_bitvec_regex_match_null_pattern(void) {
WriteFmt("Testing BitVecRegexMatch(source, NULL) - should fatal\n");
BitVec source = BitVecInit();
BitVecPush(&source, true); BitVec source = BitVecInit();
BitVecPush(&source, true);
BitVecRegexMatch(&source, NULL);
BitVecDeinit(&source);
return true; // BitVecRegexMatch tests
bool test_bitvec_regex_match_basic(void) {
WriteFmt("Testing BitVecRegexMatch basic functionality\n");
BitVec source = BitVecInit();
// 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;
}
bool test_bitvec_regex_match_null_pattern(void) {
WriteFmt("Testing BitVecRegexMatch(source, NULL) - should fatal\n");
BitVec source = BitVecInit();
BitVecPush(&source, true); BitVec source = BitVecInit();
BitVecPush(&source, true);
BitVecRegexMatch(&source, NULL);
BitVecDeinit(&source);
return true; // BitVecRegexMatch tests
bool test_bitvec_regex_match_basic(void) {
WriteFmt("Testing BitVecRegexMatch basic functionality\n");
BitVec source = BitVecInit();
// 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);
Last updated on