public void TestOneOrMoreRule() { var rule = new OneOrMoreRule(new StringRule("test ")); Assert.IsTrue(rule.Match("test something")); Assert.IsTrue((rule + new StringRule("something")).Match("test test something")); Assert.IsFalse(rule.Match("something")); }
public override string SolvePart2() { int max = _messages.Max(str => str.Length); _rules.ResetCaches(); _rules[8] = new OneOrMoreRule(_rules[42]); _rules[11] = new WrappedInTwoRulesRule(_rules[42], _rules[31], max); Regex r = new Regex("^" + _rules[0].GetRegexString() + "$"); int result = _messages.Count(message => r.IsMatch(message)); return(result.ToString()); }