示例#1
0
        public void TestBracket()
        {
            string input    = " {} {0:###} {test {nested} text} {--{{test escaped parenthesis}}--}";
            var    expected = new List <string>
            {
                "",
                "0:###",
                "nested",
                "test {nested} text",
                "--{test escaped parenthesis}--"
            };

            var result = StrHelper.ExtractTextInBrackets(input, '{', '}', false, true);

            Assert.AreEqual(result.Count, expected.Count);

            for (int i = 0; i < result.Count; i++)
            {
                Assert.AreEqual(result[i], expected[i]);
            }

            var result2 = StrHelper.ExtractTextInBrackets(input, '{', '}', false, false);

            Assert.AreEqual(result2.Count, expected.Count - 1);
            Assert.AreEqual(result2[2], expected[3]);
        }