Pchp.Library.PerlRegex.Match.GroupToStringImpl C# (CSharp) Method

GroupToStringImpl() private method

private GroupToStringImpl ( int groupnum ) : string
groupnum int
return string
        internal virtual string GroupToStringImpl(int groupnum)
        {
            int c = _matchcount[groupnum];
            if (c == 0)
                return string.Empty;

            int[] matches = _matches[groupnum];

            return _text.Substring(matches[(c - 1) * 2], matches[(c * 2) - 1]);
        }

Usage Example

        /// <summary>
        /// Given a Match, emits into the StringBuilder the evaluated
        /// substitution pattern.
        /// </summary>
        private void ReplacementImpl(StringBuilder sb, Match match)
        {
            for (int i = 0; i < _rules.Count; i++)
            {
                int r = _rules[i];
                if (r >= 0)   // string lookup
                {
                    sb.Append(_strings[r]);
                }
                else if (r < -Specials) // group lookup
                {
                    sb.Append(match.GroupToStringImpl(-Specials - 1 - r));
                }
                else
                {
                    switch (-Specials - 1 - r)
                    { // special insertion patterns
                    case LeftPortion:
                        sb.Append(match.GetLeftSubstring());
                        break;

                    case RightPortion:
                        sb.Append(match.GetRightSubstring());
                        break;

                    case LastGroup:
                        sb.Append(match.LastGroupToStringImpl());
                        break;

                    case WholeString:
                        sb.Append(match.GetOriginalString());
                        break;
                    }
                }
            }
        }
All Usage Examples Of Pchp.Library.PerlRegex.Match::GroupToStringImpl