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


C# MatchCollection.GetEnumerator方法代码示例

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


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

示例1: TextHighlighter

 public TextHighlighter(
     Page page,
     MatchCollection matches
     )
 {
     this.page = page;
     this.matchEnumerator = matches.GetEnumerator();
 }
开发者ID:n9,项目名称:pdfclown,代码行数:8,代码来源:TextHighlightSample.cs

示例2: FormatMatches

 public object FormatMatches(MatchCollection matches)
 {
     string[] strArray;
     if ((matches == null) || (matches.Count == 0))
     {
         return null;
     }
     List<object> elements = new List<object>();
     int startIndex = 0;
     using (IEnumerator enumerator = matches.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             Match current = (Match) enumerator.Current;
             string str = this.Text.Substring(startIndex, current.Index - startIndex).Replace("\t", " ").Replace("\r", "");
             if (str.Length > 0)
             {
                 strArray = str.Split(new char[] { '\n' }).Select<string, string>(((Func<string, int, string>) ((l, n) => ((n == 0) ? l : l.TrimStart(new char[0]))))).ToArray<string>();
                 if ((strArray.Length > 4) && (startIndex > 0))
                 {
                     strArray = strArray.Take<string>(2).Concat<string>("...".Split(new char[0])).Concat<string>(strArray.Skip<string>((strArray.Length - 2)).Take<string>(2)).ToArray<string>();
                 }
                 else if ((strArray.Length > 2) && (startIndex == 0))
                 {
                     strArray = strArray.Skip<string>((strArray.Length - 2)).Take<string>(2).ToArray<string>();
                     if (strArray.First<string>().Trim().Length == 0)
                     {
                         strArray = strArray.Skip<string>(1).ToArray<string>();
                     }
                 }
                 elements.Add(string.Join("\r\n", strArray));
             }
             elements.Add(Util.Highlight(current.Value));
             startIndex = current.Index + current.Length;
             if (elements.Count > 6)
             {
                 goto Label_01B9;
             }
         }
         goto Label_01E8;
     Label_01B9:
         elements.Add("...");
         return Util.WordRun(false, elements);
     }
 Label_01E8:
     if (startIndex < this.Text.Length)
     {
         strArray = this.Text.Substring(startIndex).Replace("\t", " ").Replace("\r", "").Split(new char[] { '\n' }).Select<string, string>(((Func<string, int, string>) ((l, n) => ((n == 0) ? l : l.TrimStart(new char[0]))))).ToArray<string>();
         elements.Add(string.Join("\r\n", strArray.Take<string>(2).ToArray<string>()));
     }
     return Util.WordRun(false, elements);
 }
开发者ID:CuneytKukrer,项目名称:TestProject,代码行数:52,代码来源:Query.cs


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