private static NMatchesEventArgs createNMatchesArgs(string pattern, string input)
 {
     NMatchesEventArgs args = new NMatchesEventArgs();
     args.RegexInstance = new ExtendedRegex(pattern);
     args.Matches = args.RegexInstance.Matches(input);
     return args;
 }
 public override void ExecuteMatches()
 {
     ExtendedRegex regex = getRegex();
     MatchCollection matches = regex.Matches(InputText);
     foreach (IRegexView view in m_views)
     {
         NMatchesEventArgs args = new NMatchesEventArgs();
         args.Matches = matches;
         args.RegexInstance = regex;
         view.OnMatches(args);
     }
 }
Ejemplo n.º 3
0
        public void Display(NMatchesEventArgs args)
        {
            if (args.Matches == null)
                return;

            foreach (Match match in args.Matches)
            {
                string prefix = string.Empty;
                TreeNode MatchRoot = new TreeNode(string.Format("[{0}]",match.Value));
                tree.Nodes.Add(MatchRoot);
                DisplayGroups(args, match, MatchRoot);
                MatchRoot.Expand();
            }
        }
Ejemplo n.º 4
0
        private static void DisplayGroups(NMatchesEventArgs args, Match match, TreeNode MatchRoot)
        {
            const int DEFAULT_GROUP_INDEX = 1;
            if (match.Groups.Count <= DEFAULT_GROUP_INDEX)
                return;

            for (int i = DEFAULT_GROUP_INDEX; i < match.Groups.Count; i++)
            {
                Group group = match.Groups[i];
                string groupName = args.RegexInstance.GroupNameFromNumber(i);
                string finalNodeText = string.Empty;

                if(groupName!=string.Empty)
                    finalNodeText= string.Format("{1}:[{0}]", group.Value, groupName);
                else
                    finalNodeText = string.Format("{1}:[{0}]", group.Value, i);

                TreeNode groupRoot = new TreeNode(finalNodeText);
                MatchRoot.Nodes.Add(groupRoot);

                DisplayCaptures(group, groupRoot);
            }
        }