Пример #1
0
        static void Main(string[] args)
        {
            RegexBuilder r = new RegexBuilder();

            r.args = args;

            Application.Run(r);
        }
Пример #2
0
        private void performRegexComparison()
        {
            treeResults.Nodes.Clear();
            lblRegexError.Text = string.Empty;
            RegexBuilder builder = new RegexBuilder();
            RegexOptions options = builder.setOptions(false, chkCultureInvariant.Checked, false, chkExplicitCapture.Checked,
            chkIgnoreCase.Checked, chkIgnorePatternWhitespace.Checked, chkMultiline.Checked, false, false, chkSingleline.Checked);

            try
            {
                if (!string.IsNullOrEmpty(txtRegexInput_search.Text))
                {
                    Regex rgx = builder.GetRegex(txtRegexInput_search.Text, options);
                    MatchCollection mch = rgx.Matches(txtSearchForMatch_search.Text);
                    if (mch.Count > 0)
                    {   
                        int count = 1;
                        foreach (Match match in mch)
                        {
                            TreeNode node = new TreeNode("Match " + count);
                            foreach (Group item in match.Groups)
                            {
                                TreeNode nodeMatch = new TreeNode(item.Value);

                                node.Nodes.Add(nodeMatch);
                            }
                            treeResults.Nodes.Add(node);
                            count++;
                        }
                    }
                    else
                    {
                        treeResults.Nodes.Add("No matches found");
                    }
                    txtTextReplacedByRegex.Text = rgx.Replace(txtSearchForMatch_search.Text, txtRegexReplaceWith.Text);   
                }
            }
            catch (ArgumentException ex)
            {
                lblRegexError.Text = ex.Message;
            }
        }