BitVecRegexMatch

Table of Contents

BitVecRegexMatch

Description

Simple regex-style pattern matching for bitvectors. Supports basic patterns: ‘*’ (any sequence), ‘?’ (0 or 1), ‘[01]’ (literal).

Parameters

NameDirectionDescription
bvinBitvector to match against
patterninPattern string using regex syntax

Usage example (from documentation)

  bool matches = BitVecRegexMatch(&data, "10*01");  // 10 followed by any bits, then 01

Usage example (Cross-references)

    }
    
    bool BitVecRegexMatch(BitVec *bv, const char *pattern) {
    ValidateBitVec(bv);
    if (!pattern) {
    // 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;
    
    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);

Share :

Related Posts

BitVecFindLastPattern

BitVecFindLastPattern Description Find last occurrence of a bit pattern in the bitvector.

Read More

BitVecFuzzyMatch

BitVecFuzzyMatch Description Fuzzy pattern matching allowing up to N mismatches. Useful for approximate pattern matching with error tolerance.

Read More

BitVecFindAllPattern

BitVecFindAllPattern Description Find all occurrences of a bit pattern in the bitvector. Results array must be pre-allocated with sufficient space.

Read More