示例#1
0
        public CompactRegexMatches(string input, Match match)
        {
            this.input = input;
            this.found = false;
            List <CompactRegexMatch> matchList = new List <CompactRegexMatch>();

            while (match.Success)
            {
                this.found = true;
                CompactRegexMatch regexMatch = new CompactRegexMatch();
                regexMatch.value = match.Value;
                bool          firstGroup  = true;
                bool          secondGroup = true;
                StringBuilder sb          = new StringBuilder();
                foreach (Group group in match.Groups)
                {
                    if (firstGroup)
                    {
                        firstGroup = false;
                        continue;
                    }

                    if (!secondGroup)
                    {
                        sb.Append(' ');
                    }
                    secondGroup = false;
                    sb.Append('(');

                    bool firstCapture = true;
                    foreach (Capture capture in group.Captures)
                    {
                        if (!firstCapture)
                        {
                            sb.Append(", ");
                        }
                        sb.AppendFormat("\"{0}\"", capture.Value);
                        firstCapture = false;
                    }
                    sb.Append(')');
                }
                regexMatch.groups = sb.ToString();
                matchList.Add(regexMatch);
                match = match.NextMatch();
            }
            matches = matchList.ToArray();
        }
示例#2
0
        public CompactRegexMatches(string input, Match match)
        {
            this.input = input;
            this.found = false;
            List<CompactRegexMatch> matchList = new List<CompactRegexMatch>();
            while (match.Success)
            {
                this.found = true;
                CompactRegexMatch regexMatch = new CompactRegexMatch();
                regexMatch.value = match.Value;
                bool firstGroup = true;
                bool secondGroup = true;
                StringBuilder sb = new StringBuilder();
                foreach (Group group in match.Groups)
                {
                    if (firstGroup)
                    {
                        firstGroup = false;
                        continue;
                    }

                    if (!secondGroup)
                        sb.Append(' ');
                    secondGroup = false;
                    sb.Append('(');

                    bool firstCapture = true;
                    foreach (Capture capture in group.Captures)
                    {
                        if (!firstCapture)
                            sb.Append(", ");
                        sb.AppendFormat("\"{0}\"", capture.Value);
                        firstCapture = false;
                    }
                    sb.Append(')');
                }
                regexMatch.groups = sb.ToString();
                matchList.Add(regexMatch);
                match = match.NextMatch();
            }
            matches = matchList.ToArray();
        }