public static List <RegexStruct> GetRegexs() { var listStruct = new List <RegexStruct>(); var a = new RegExp("a"); var b = new RegExp("b"); var int1 = "aba(a*|b*)* begint met aba"; var reg1 = a.dot(b).dot(a).dot(a.or(b).star()); var reg2 = new RegExp("a").dot(new RegExp("a").star()).dot(new RegExp("b").dot(new RegExp("b").star())); var reg3 = new RegExp("a").or(new RegExp("b")); var reg4 = new RegExp("a").plus().dot(new RegExp("a").star()).dot(new RegExp("b").plus()); var reg5 = new RegExp("a").dot(new RegExp("a").star()).dot(new RegExp("b").dot(new RegExp("b").star())); listStruct.Add(new RegexStruct { text = int1, regex = reg1 }); listStruct.Add(new RegexStruct { regex = reg2, text = "a+b+" }); listStruct.Add(new RegexStruct { regex = reg3.star(), text = "(a|b)*" }); listStruct.Add(new RegexStruct { regex = reg4, text = "a+(a*)b+" }); listStruct.Add(new RegexStruct { regex = reg5, text = "a a* b b*" }); return(listStruct); }
public static void TestRegToAutomaat() { //(a|b)* var regex = new RegExp("a"); regex = regex.or(new RegExp("b")); regex = regex.star(); TestRegex(regex); //((ab))+ regex = new RegExp("a"); regex = regex.dot(new RegExp("b")); regex = regex.plus(); TestRegex(regex); //((a|b)|(a|d)) RegExp rA, rB, rC, rD, reg; rA = new RegExp("a"); rB = new RegExp("b"); rC = new RegExp("c"); rD = new RegExp("d"); reg = rA.or(rB); reg = reg.or(rC.or(rD)); TestRegex(reg); }
public TestRegExp() { a = new RegExp("a"); b = new RegExp("b"); // expr1: "baa" expr1 = new RegExp("baa"); // expr2: "bb" expr2 = new RegExp("bb"); // expr3: "baa | baa" expr3 = expr1.or(expr2); // all: "(a|b)*" all = (a.or(b)).star(); // expr4: "(baa | baa)+" expr4 = expr3.plus(); // expr5: "(baa | baa)+ (a|b)*" expr5 = expr4.dot(all); }