Esempio n. 1
0
        static void TestRegex()
        {
            string pattern = "[abc]+bc";

            /* Buglist:
             * List matching rules are too greedy. They need to stop so that the next terms succeed, if any.
             * "a+." fails on "aaaa" but not on "aaab" because a+ matches to the end.
             */

            List <string> testStrings = new List <string> {
                "processing", "aaaaa", "\\^2", "abc123", "123abc", "aabbcc", "cde1b2c3", "d.txt", "word10", "12dddaaa24", "aaaaaaaaaab"
            };


            Console.WriteLine(new String('*', 10));
            foreach (var s in testStrings)
            {
                try
                {
                    Console.WriteLine("Regex:{0} => {1}", s, new Regex(pattern).Match(s).Value);
                }
                catch (ArgumentException e)
                {
                    Console.WriteLine("Regex:{0} => {1}", s, e.Message);
                }

                MyRegex r = new MyRegex(pattern);
                r.Run(s, out string myResult);
                Console.WriteLine("Mine :{0} => {1}\n", s, myResult ?? "Regex Failure!");
            }
        }
Esempio n. 2
0
 static void TestBraceMatch()
 {
     string[] testStrings = { " ", "a", ",", "{", "{ ", "{,", "{a", "{1", "{5}", "{3,}", "{0,9}", "{ 1 , 5 }" };
     foreach (string str in testStrings)
     {
         if (MyRegex.TryMatchBraceQuantifier(new ParserString(str), out Quantifier result, out ParserString parserString))
         {
             Console.WriteLine("{0} => Success: {1}", str, result);
         }