当前位置: 首页>>代码示例>>C#>>正文


C# Matcher.Group方法代码示例

本文整理汇总了C#中Matcher.Group方法的典型用法代码示例。如果您正苦于以下问题:C# Matcher.Group方法的具体用法?C# Matcher.Group怎么用?C# Matcher.Group使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matcher的用法示例。


在下文中一共展示了Matcher.Group方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: expand

        /// <summary>
        /// Similar to Python expand, return expansion where every \1, \2, etc. is
        /// replaced by match.group(1), match.group(2), etc.  Note: Even though this is
        /// a general utility function, we define it locally because it is only tested
        /// to work in the cases used by this class.
        /// </summary>
        ///
        /// <param name="match">The match object from String.match.</param>
        /// <param name="expansion">The string with \1, \2, etc. to replace from match.</param>
        /// <returns>The expanded string.</returns>
        private static String expand(Matcher match, String expansion)
        {
            String result = "";
            int beginIndex = 0;
            Pattern regex = ILOG.J2CsMapping.Text.Pattern.Compile("\\\\(\\d)");
            Matcher expansionMatcher = regex.Matcher(expansion);
            while (expansionMatcher.Find()) {
                result += expansion.Substring(beginIndex,(expansionMatcher.start())-(beginIndex));
                result += match.Group(Int32.Parse(expansionMatcher.Group(1)));
                beginIndex = expansionMatcher.end();
            }

            // Add the substring after the last match.
            result += expansion.Substring(beginIndex,(expansion.Length)-(beginIndex));
            return result;
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:26,代码来源:ConfigPolicyManager.cs


注:本文中的Matcher.Group方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。