예제 #1
0
        public void should_split_string()
        {
            var re     = new PcreRegex(@"\s+");
            var result = re.Split("foo bar   baz").ToList();

            Assert.That(result, Is.EqualTo(new[] { "foo", "bar", "baz" }));
        }
예제 #2
0
        public void should_split_on_empty_pattern()
        {
            var re     = new PcreRegex(@"");
            var result = re.Split("foo").ToList();

            Assert.That(result, Is.EqualTo(new[] { "", "f", "o", "o", "" }));
        }
예제 #3
0
        public void should_not_include_captured_groups_in_result_if_not_specified()
        {
            var re     = new PcreRegex(@"<(\d)?(.+?)>");
            var result = re.Split("foo<bar>baz<42>a").ToList();

            Assert.That(result, Is.EqualTo(new[] { "foo", "baz", "a" }));
        }
예제 #4
0
        public void should_include_empty_groups_in_result()
        {
            var re     = new PcreRegex(@"<(\d?)(.+?)>");
            var result = re.Split("foo<bar>baz<42>a", PcreSplitOptions.IncludeGroupValues).ToList();

            Assert.That(result, Is.EqualTo(new[] { "foo", "", "bar", "baz", "4", "2", "a" }));
        }
예제 #5
0
        public void should_not_split_when_given_count_is_zero()
        {
            var re     = new PcreRegex(@"\s+");
            var result = re.Split("foo bar baz", 0).ToList();

            Assert.That(result, Is.EqualTo(new[] { "foo bar baz" }));
        }
예제 #6
0
        public void should_split_string_starting_at_given_index_and_up_to_given_part_count()
        {
            var re     = new PcreRegex(@"\s+");
            var result = re.Split("foo bar   baz  abc def", 2, 6).ToList();

            Assert.That(result, Is.EqualTo(new[] { "foo bar", "baz", "abc def" }));
        }
예제 #7
0
        public void should_split_string_starting_at_given_index()
        {
            var re     = new PcreRegex(@"\s+");
            var result = re.Split("foo bar   baz  abc def", -1, 12).ToList();

            Assert.That(result, Is.EqualTo(new[] { "foo bar   baz", "abc", "def" }));
        }
예제 #8
0
        public void should_split_string_up_to_given_part_count()
        {
            var re     = new PcreRegex(@"\s+");
            var result = re.Split("foo bar   baz  abc", 2).ToList();

            Assert.That(result, Is.EqualTo(new[] { "foo", "bar", "baz  abc" }));
        }
예제 #9
0
        public void should_split_string_at_start_and_end()
        {
            var re     = new PcreRegex(@"\s+");
            var result = re.Split("  foo bar   baz ").ToList();

            Assert.That(result, Is.EqualTo(new[] { string.Empty, "foo", "bar", "baz", string.Empty }));
        }
예제 #10
0
            static ImmutableArray <Bank> ParseBanksFromContent(string str)
            {
                var trimmed = str.Trim();

                return(PcreRegex.Split(trimmed, @"\s+")
                       .Select(str => new Bank(uint.Parse(str.AsSpan())))
                       .ToImmutableArray());
            }