Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            var ValidFirstChar = EnglishLetterOrHyphen;
            var ValidChars     = EnglishLetterOrHyphenOrDigit & '.' & '-';

            var email = WordEdge +
                        ValidFirstChar +
                        ValidChars[0, 19] +
                        "@" +
                        ValidFirstChar +
                        ValidChars[2, 14] +
                        "." +
                        ValidFirstChar +
                        ValidChars[1, 9] +
                        WordEdge;

            textBox1.Text = email.ToString();

            var vrx = new Verex(email);
            var txt = "My email is [email protected] .";
            var m   = vrx.Match(txt);

            if (m.Success)
            {
                MessageBox.Show(m.Value);
            }
        }
Пример #2
0
        public void TestBalancingGroup()
        {
            Assert.ThrowsException <ArgumentNullException>(() => new BalancingGroupPattern(("group1", "group2")));
            Assert.AreEqual(new BalancingGroupPattern("group1", "abc".AsItIs()).Expression, "(?'-group1'abc)");
            Assert.AreEqual(new BalancingGroupPattern(("group1", "group2"), "abc").Expression, "(?'group2-group1'abc)");
            Assert.AreEqual(Patterns.BalancedBracketsContent('[', ']').Expression, @"^[^]\[]*(?:(?:(?'Open'\[)[^]\[]*)+(?:(?'Close-Open'])[^]\[]*)+)*(?(Open)(?!))$");

            Assert.AreEqual(Verex.ContainsBalancedBrackets(
                                "(2 + 1) * (3 + 2) - ( 1 + 4)",
                                "(", ")"), true);

            Assert.AreEqual(Verex.ContainsBalancedBrackets(
                                "(2 + 1) * ((3 + 2) - ( 1 + 4)",
                                "(", ")"), false);

            Assert.AreEqual(Verex.ContainsBalancedBrackets(
                                "=>=>x + 2<= * =>4 + 3<=<= / 2", "=>", "<="), true);

            Assert.AreEqual(Verex.ContainsBalancedBrackets(
                                "=>=>x + 2<= * =>4 + 3<= / 2", "=>", "<="), false);

            string input = "<!--<!--x+2> * <!--4+3>>/2";
            var    x     = Verex.BalancedContents(input, "<!--", ">");

            Assert.AreEqual(Join(x), @"<!--x+2> * <!--4+3>, x+2, 4+3, ");

            input = "<!--<!--x+2=> * <!--4+3=>=>/2";
            x     = Verex.BalancedContents(input, "<!--", "=>");

            Assert.AreEqual(Join(x), @"<!--x+2=> * <!--4+3=>, x+2, 4+3, ");

            input = " 'y' 'x+2' * '4+3'/2";
            x     = Verex.BalancedContents(input, "'", "'");

            Assert.AreEqual(Join(x), @"y' 'x+2' * '4+3,  'x+2' * , x+2, ");

            input = "--y-- --x+2-- * --4+3--/2";
            x     = Verex.BalancedContents(input, "--", "--");

            Assert.AreEqual(Join(x), @"y-- --x+2-- * --4+3,  --x+2-- * , x+2, ");
        }