6 releases

0.3.0 Nov 16, 2024
0.2.2 Nov 1, 2024
0.2.1 Oct 31, 2024
0.1.1 Oct 6, 2024

#407 in Algorithms

Download history 236/week @ 2024-10-04 206/week @ 2024-10-11 18/week @ 2024-10-18 51/week @ 2024-10-25 178/week @ 2024-11-01 2/week @ 2024-11-08 113/week @ 2024-11-15 8/week @ 2024-11-22 2/week @ 2024-11-29

128 downloads per month

MIT license

315KB
7.5K SLoC

RegexSolver

Crates.io Version

This repository contains the code of RegexSolver engine.

For more information, you can check the library's documentation.

If you want to use this library with other programming languages, we provide a wide range of wrappers:

For more information about how to use the wrappers, you can refer to our getting started guide.

Installation

Add the following line in your Cargo.toml:

[dependencies]
regexsolver = "0.2"

Examples

Union

use regexsolver::Term;

let term1 = Term::from_regex("abc").unwrap();
let term2 = Term::from_regex("de").unwrap();
let term3 = Term::from_regex("fghi").unwrap();

let union = term1.union(&[term2, term3]).unwrap();

if let Term::RegularExpression(regex) = union {
    println!("{}", regex.to_string()); // (abc|de|fghi)
}

Intersection

use regexsolver::Term;

let term1 = Term::from_regex("(abc|de){2}").unwrap();
let term2 = Term::from_regex("de.*").unwrap();
let term3 = Term::from_regex(".*abc").unwrap();

let intersection = term1.intersection(&[term2, term3]).unwrap();

if let Term::RegularExpression(regex) = intersection {
    println!("{}", regex.to_string()); // deabc
}

Difference/Subtraction

use regexsolver::Term;

let term1 = Term::from_regex("(abc|de)").unwrap();
let term2 = Term::from_regex("de").unwrap();

let subtraction = term1.subtraction(&term2).unwrap();

if let Term::RegularExpression(regex) = subtraction {
    println!("{}", regex.to_string()); // abc
}

Dependencies

~6.5–9MB
~170K SLoC