本文整理匯總了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();
}
示例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);
}