Esempio n. 1
0
        public void Can_Split_And_Remove_Empty_Entries()
        {
            var input   = "x hello x world x goodbye !x world!";
            var pattern = @"\s*[x!]\s*";

            string[] expected = { "hello", "world", "goodbye", "world" };

            var result = RegexUtility.SplitRemoveEmptyEntries(input, pattern);

            result.ShouldBe(expected);
        }
Esempio n. 2
0
        public void Can_Split_And_Remove_Empty_Entries_And_Use_RegexOptions_To_Ignore_Case()
        {
            var input   = "x hello X world x goodbye !X world!";
            var pattern = @"\s*[X!]\s*";

            string[] expected = { "hello", "world", "goodbye", "world" };

            var result = RegexUtility.SplitRemoveEmptyEntries(input, pattern, RegexOptions.IgnoreCase);

            result.ShouldBe(expected);
        }
        public void SplitRemoveEmptyEntries_Matches_Core_Split_With_Same_Option()
        {
            string input = "() Hello . World?";

            string[] delimiters = { "()", ".", "?" };
            string[] expected   = { " Hello ", " World" };

            var coreSplit = RegexUtility.Split(input, delimiters, splitOptions: SplitOptions.RemoveEmptyEntries);
            var result    = RegexUtility.SplitRemoveEmptyEntries(input, delimiters);

            result.ShouldBe(coreSplit);
            result.ShouldBe(expected);
        }