本文整理匯總了C#中System.Text.RegularExpressions.MatchCollection.Cast方法的典型用法代碼示例。如果您正苦於以下問題:C# MatchCollection.Cast方法的具體用法?C# MatchCollection.Cast怎麽用?C# MatchCollection.Cast使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Text.RegularExpressions.MatchCollection
的用法示例。
在下文中一共展示了MatchCollection.Cast方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetAllImagesUrls
/// <summary>
/// using a regular expression, find all of the href or urls
/// in the content of the page
/// </summary>
/// <param name="content"></param>
private void GetAllImagesUrls( string content )
{
//regular expression Responsible for finding all images on html document.
string Pattern = @"(http://)[A-Za-z0-9\-\.]+\.[A-Za-z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*[^\.\,\)\(\s].(jpg|.png|.gif|.tiff)";
Regex Regex = new Regex(Pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
Matches = Regex.Matches(content);
ListOfDistinctMatches = Matches.Cast<Match>().Select(m => m.Value).Distinct().ToList();
}
示例2: PreProcessPacket
public static List<string> PreProcessPacket(MatchCollection matches)
{
var list = (matches.Cast<Match>().Select(line => line.Value.Trim())).ToList();
return list;
}