예제 #1
0
파일: TRegex.cs 프로젝트: szliyang/Toolbox
        public void Replace_String()
        {
            var test     = "It's a question of LUst, it's a question of TRust";
            var expected = "It's a question of love, it's a question of love";
            var actual   = TRegex.Replace(test, "(l|tr)ust", "love");

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
파일: TRegex.cs 프로젝트: szliyang/Toolbox
        public void Replace_Eval()
        {
            var test     = "It's a question of LUst, it's a question of TRust";
            var expected = "It's a question of trust, it's a question of lust";
            var actual   = TRegex.Replace(test, "(l|tr)ust", m => {
                if (m.Value == "LUst")
                {
                    return("trust");
                }
                else if (m.Value == "TRust")
                {
                    return("lust");
                }
                else
                {
                    return("???");
                }
            });

            Assert.AreEqual(expected, actual);
            StringAssert.DoesNotMatch(actual, new Regex(@"\?\?\?"));
        }