예제 #1
0
        public void BlockParser_Parses()
        {
            string         content = "1\n2\n3\n<-target->\n1\n2\n3\n<-target->\n1\n5\n3";
            StringBuilder  result  = new StringBuilder();
            RangeExtractor parser  = new RangeExtractor("-target-", "<", ">");

            somContext.Content = content;
            foreach (var item in parser.Parse(somContext))
            {
                result.Append(item);
            }
            Assert.AreEqual("<-target-><-target->", result.ToString());
        }
예제 #2
0
        public string Interpret(string content)
        {
            MatchCollection matches = Regex.Matches(content, "['|\"](\\d{5})");

            foreach (Match match in matches)
            {
                string targetmatch = match.Groups[0].Value;
                string pk          = match.Groups[1].Value;
                if (!FoundKeys.ContainsKey(pk))
                {
                    FoundKeys.Add(pk, targetmatch);
                    RangeExtractor parser = new RangeExtractor(targetmatch, "<tr", "/tr>");
                    foreach (var item in parser.Parse(content))
                    {
                        content = content.Replace(item, string.Format("{0}{2}{1}\n", Utils.QuestionInfo(pk), item, Utils.prefix));
                    }
                }
            }
            return(content);
        }