public void OptionallyQuoted()
        {
            scanner=@"key[value='this ""is \' a quoted value']";
            StringScanner inner = scanner.ExpectAlpha()
                .Get(MatchFunctions.Bounded);

            scanner.AssertFinished();

            inner.Expect(MatchFunctions.HTMLAttribute)
                .Expect("=");

            var optQuote = new OptionallyQuoted();
            optQuote.Terminators="]";

            string text = inner.Get(optQuote);
            Assert.AreEqual("this \"is ' a quoted value",text,"Got the right text");

            inner.Text = @"this ""is \' a quoted value";
            text = inner.Get(optQuote);
            Assert.AreEqual("this \"is \\' a quoted value",text, "Got the right text without quotes");

            inner.Text = @"""this is \"" a quoted value""";
            text = inner.Get(optQuote);
            Assert.AreEqual("this is \" a quoted value", text, "Got the right text with quotes");


        }
Example #2
0
 protected IExpectPattern expectsOptionallyQuotedValue()
 {
     var pattern = new OptionallyQuoted();
     pattern.Terminators = Objects.Enumerate(']');
     return pattern;
 }