Skip to content

Regex Matcher Fails On Valid Inputs #214

@adamrodger

Description

@adamrodger

The regex library used by pact_matching fails on valid input. Take the following example:

use onig::Regex;

fn main() {
    let regex_string = "Greater|GreaterOrEqual";

    let re = Regex::new(regex_string).unwrap();

    println!("Regex: {regex_string}");
    check(&re, "Greater");
    check(&re, "GreaterOrEqual");
}

fn check(regex: &Regex, input: &str) {
    let matched = regex.is_match(input);
    println!("Input: {input} - {matched}");
}

This produces the output:

Regex: Greater|GreaterOrEqual
Input: Greater - true
Input: GreaterOrEqual - false

If you swap the regex around to the opposite order then it passes:

Regex: GreaterOrEqual|Greater
Input: Greater - true
Input: GreaterOrEqual - true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions