1use grex::RegExpBuilder;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub struct GrexOptions {
7 pub digit: bool,
8 pub anchors: bool,
9 pub case_insensitive: bool,
10}
11
12impl Default for GrexOptions {
13 fn default() -> Self {
14 Self {
15 digit: true,
16 anchors: true,
17 case_insensitive: false,
18 }
19 }
20}
21
22pub fn generate(examples: &[String], options: GrexOptions) -> String {
23 if examples.is_empty() {
24 return String::new();
25 }
26 let mut builder = RegExpBuilder::from(examples);
27 if options.digit {
28 builder.with_conversion_of_digits();
29 }
30 if !options.anchors {
31 builder.without_anchors();
32 }
33 if options.case_insensitive {
34 builder.with_case_insensitive_matching();
35 }
36 builder.build()
37}