예제 #1
0
        public void TestLookAroundNodeNullAssignment3()
        {
            RegexNodeLookAround lookAround = new RegexNodeLookAround(RegexLookAround.PositiveLookAhead, new RegexNodeLiteral("abc"), new RegexNodeLiteral("abc"));

            lookAround.MatchExpression = null;
            Assert.IsNull(lookAround);
        }
        public void TestLookAroundNodeRendering()
        {
            RegexNodeLiteral lookupExpression = new RegexNodeLiteral(@"a\bc");
            RegexNodeLiteral matchExpression  = new RegexNodeLiteral(@"\w+");

            RegexNodeLookAround positiveLookAhead = new RegexNodeLookAround(RegexLookAround.PositiveLookAhead, lookupExpression, matchExpression);

            Assert.AreEqual(@"(?:\w+(?=a\bc))", positiveLookAhead.ToRegexPattern());
            positiveLookAhead.Quantifier = RegexQuantifier.ZeroOrMore;
            Assert.AreEqual(@"(?:\w+(?=a\bc))*", positiveLookAhead.ToRegexPattern());

            RegexNodeLookAround positiveLookBehind = new RegexNodeLookAround(RegexLookAround.PositiveLookBehind, lookupExpression, matchExpression);

            Assert.AreEqual(@"(?:(?<=a\bc)\w+)", positiveLookBehind.ToRegexPattern());
            positiveLookBehind.Quantifier = RegexQuantifier.ZeroOrMore;
            Assert.AreEqual(@"(?:(?<=a\bc)\w+)*", positiveLookBehind.ToRegexPattern());

            RegexNodeLookAround negativeLookAhead = new RegexNodeLookAround(RegexLookAround.NegativeLookAhead, lookupExpression, matchExpression);

            Assert.AreEqual(@"(?:\w+(?!a\bc))", negativeLookAhead.ToRegexPattern());
            negativeLookAhead.Quantifier = RegexQuantifier.ZeroOrMore;
            Assert.AreEqual(@"(?:\w+(?!a\bc))*", negativeLookAhead.ToRegexPattern());

            RegexNodeLookAround negativeLookBehind = new RegexNodeLookAround(RegexLookAround.NegativeLookBehind, lookupExpression, matchExpression);

            Assert.AreEqual(@"(?:(?<!a\bc)\w+)", negativeLookBehind.ToRegexPattern());
            negativeLookBehind.Quantifier = RegexQuantifier.ZeroOrMore;
            Assert.AreEqual(@"(?:(?<!a\bc)\w+)*", negativeLookBehind.ToRegexPattern());

            RegexNodeLookAround positiveLookAhead2 = RegexBuilder.PositiveLookAhead(lookupExpression, matchExpression);

            Assert.AreEqual(@"(?:\w+(?=a\bc))", positiveLookAhead2.ToRegexPattern());
            positiveLookAhead2 = RegexBuilder.PositiveLookAhead(lookupExpression, matchExpression, RegexQuantifier.ZeroOrMore);
            Assert.AreEqual(@"(?:\w+(?=a\bc))*", positiveLookAhead2.ToRegexPattern());

            RegexNodeLookAround positiveLookBehind2 = RegexBuilder.PositiveLookBehind(lookupExpression, matchExpression);

            Assert.AreEqual(@"(?:(?<=a\bc)\w+)", positiveLookBehind2.ToRegexPattern());
            positiveLookBehind2 = RegexBuilder.PositiveLookBehind(lookupExpression, matchExpression, RegexQuantifier.ZeroOrMore);
            Assert.AreEqual(@"(?:(?<=a\bc)\w+)*", positiveLookBehind2.ToRegexPattern());

            RegexNodeLookAround negativeLookAhead2 = RegexBuilder.NegativeLookAhead(lookupExpression, matchExpression);

            Assert.AreEqual(@"(?:\w+(?!a\bc))", negativeLookAhead2.ToRegexPattern());
            negativeLookAhead2 = RegexBuilder.NegativeLookAhead(lookupExpression, matchExpression, RegexQuantifier.ZeroOrMore);
            Assert.AreEqual(@"(?:\w+(?!a\bc))*", negativeLookAhead2.ToRegexPattern());

            RegexNodeLookAround negativeLookBehind2 = RegexBuilder.NegativeLookBehind(lookupExpression, matchExpression);

            Assert.AreEqual(@"(?:(?<!a\bc)\w+)", negativeLookBehind2.ToRegexPattern());
            negativeLookBehind2 = RegexBuilder.NegativeLookBehind(lookupExpression, matchExpression, RegexQuantifier.ZeroOrMore);
            Assert.AreEqual(@"(?:(?<!a\bc)\w+)*", negativeLookBehind2.ToRegexPattern());
        }
예제 #3
0
 public void TestLookAroundNodeNullAssignment3()
 {
     RegexNodeLookAround lookAround = new RegexNodeLookAround(RegexLookAround.PositiveLookAhead, new RegexNodeLiteral("abc"), new RegexNodeLiteral("abc"));
     lookAround.MatchExpression = null;
     Assert.IsNull(lookAround);
 }
예제 #4
0
 public void TestLookAroundNodeNullAssignment1()
 {
     RegexNodeLookAround lookAround = new RegexNodeLookAround(RegexLookAround.PositiveLookAhead, null, null);
     Assert.IsNull(lookAround);
 }
예제 #5
0
        public void TestLookAroundNodeNullAssignment1()
        {
            RegexNodeLookAround lookAround = new RegexNodeLookAround(RegexLookAround.PositiveLookAhead, null, null);

            Assert.IsNull(lookAround);
        }
        public void TestLookAroundNodeRendering()
        {
            RegexNodeLiteral lookupExpression = new RegexNodeLiteral(@"a\bc");
            RegexNodeLiteral matchExpression = new RegexNodeLiteral(@"\w+");

            RegexNodeLookAround positiveLookAhead = new RegexNodeLookAround(RegexLookAround.PositiveLookAhead, lookupExpression, matchExpression);
            Assert.AreEqual(@"(?:\w+(?=a\bc))", positiveLookAhead.ToRegexPattern());
            positiveLookAhead.Quantifier = RegexQuantifier.ZeroOrMore;
            Assert.AreEqual(@"(?:\w+(?=a\bc))*", positiveLookAhead.ToRegexPattern());

            RegexNodeLookAround positiveLookBehind = new RegexNodeLookAround(RegexLookAround.PositiveLookBehind, lookupExpression, matchExpression);
            Assert.AreEqual(@"(?:(?<=a\bc)\w+)", positiveLookBehind.ToRegexPattern());
            positiveLookBehind.Quantifier = RegexQuantifier.ZeroOrMore;
            Assert.AreEqual(@"(?:(?<=a\bc)\w+)*", positiveLookBehind.ToRegexPattern());

            RegexNodeLookAround negativeLookAhead = new RegexNodeLookAround(RegexLookAround.NegativeLookAhead, lookupExpression, matchExpression);
            Assert.AreEqual(@"(?:\w+(?!a\bc))", negativeLookAhead.ToRegexPattern());
            negativeLookAhead.Quantifier = RegexQuantifier.ZeroOrMore;
            Assert.AreEqual(@"(?:\w+(?!a\bc))*", negativeLookAhead.ToRegexPattern());

            RegexNodeLookAround negativeLookBehind = new RegexNodeLookAround(RegexLookAround.NegativeLookBehind, lookupExpression, matchExpression);
            Assert.AreEqual(@"(?:(?<!a\bc)\w+)", negativeLookBehind.ToRegexPattern());
            negativeLookBehind.Quantifier = RegexQuantifier.ZeroOrMore;
            Assert.AreEqual(@"(?:(?<!a\bc)\w+)*", negativeLookBehind.ToRegexPattern());

            RegexNodeLookAround positiveLookAhead2 = RegexBuilder.PositiveLookAhead(lookupExpression, matchExpression);
            Assert.AreEqual(@"(?:\w+(?=a\bc))", positiveLookAhead2.ToRegexPattern());
            positiveLookAhead2 = RegexBuilder.PositiveLookAhead(lookupExpression, matchExpression, RegexQuantifier.ZeroOrMore);
            Assert.AreEqual(@"(?:\w+(?=a\bc))*", positiveLookAhead2.ToRegexPattern());

            RegexNodeLookAround positiveLookBehind2 = RegexBuilder.PositiveLookBehind(lookupExpression, matchExpression);
            Assert.AreEqual(@"(?:(?<=a\bc)\w+)", positiveLookBehind2.ToRegexPattern());
            positiveLookBehind2 = RegexBuilder.PositiveLookBehind(lookupExpression, matchExpression, RegexQuantifier.ZeroOrMore);
            Assert.AreEqual(@"(?:(?<=a\bc)\w+)*", positiveLookBehind2.ToRegexPattern());

            RegexNodeLookAround negativeLookAhead2 = RegexBuilder.NegativeLookAhead(lookupExpression, matchExpression);
            Assert.AreEqual(@"(?:\w+(?!a\bc))", negativeLookAhead2.ToRegexPattern());
            negativeLookAhead2 = RegexBuilder.NegativeLookAhead(lookupExpression, matchExpression, RegexQuantifier.ZeroOrMore);
            Assert.AreEqual(@"(?:\w+(?!a\bc))*", negativeLookAhead2.ToRegexPattern());

            RegexNodeLookAround negativeLookBehind2 = RegexBuilder.NegativeLookBehind(lookupExpression, matchExpression);
            Assert.AreEqual(@"(?:(?<!a\bc)\w+)", negativeLookBehind2.ToRegexPattern());
            negativeLookBehind2 = RegexBuilder.NegativeLookBehind(lookupExpression, matchExpression, RegexQuantifier.ZeroOrMore);
            Assert.AreEqual(@"(?:(?<!a\bc)\w+)*", negativeLookBehind2.ToRegexPattern());
        }