Example #1
0
        public void Backreference_Number()
        {
            var regex = RegularExpression.Of(
                CaptureGroup.Of(Quantifiers.OneOrMore(Literal.For("a"))),
                Quantifiers.ZeroOrMore(Literal.For("b")),
                Backreference.For(1)
                ).ToRegex();

            Assert.AreEqual(@"(a+)b*\1", regex.ToString());
        }
Example #2
0
        public void Backreference_Name_WithQuotes()
        {
            var regex = RegularExpression.Of(
                CaptureGroup.Of(new CaptureGroupOptions()
            {
                Name = "a", UseQuotes = true
            }, Quantifiers.OneOrMore(Literal.For("a"))),
                Quantifiers.ZeroOrMore(Literal.For("b")),
                Backreference.For("a", true)
                ).ToRegex();

            Assert.AreEqual(@"(?'a'a+)b*\k'a'", regex.ToString());
        }
Example #3
0
        public void Backreference_Name()
        {
            var regex = RegularExpression.Of(
                CaptureGroup.Of(new CaptureGroupOptions()
            {
                Name = "a"
            }, Quantifiers.OneOrMore(Literal.For("a"))),
                Quantifiers.ZeroOrMore(Literal.For("b")),
                Backreference.For("a")
                ).ToRegex();

            Assert.AreEqual(@"(?<a>a+)b*\k<a>", regex.ToString());
        }