本文整理汇总了C#中System.Text.RegularExpressions.Regex.Any方法的典型用法代码示例。如果您正苦于以下问题:C# Regex.Any方法的具体用法?C# Regex.Any怎么用?C# Regex.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.RegularExpressions.Regex
的用法示例。
在下文中一共展示了Regex.Any方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsApplicable
private static bool IsApplicable(Regex[] filters, string name)
{
return filters.Length == 0 || !filters.Any(filter => filter.IsMatch(name));
}
示例2: GetAllPagesUnderWithDocument
/// <summary>
/// Get every WebPage.Internal on a web site (or part of a web site) visiting all internal links just once
/// plus every external page (or other Url) linked to the web site as a WebPage.External
/// </summary>
/// <remarks>
/// Use .OfType WebPage.Internal to get just the internal ones if that's what you want
/// </remarks>
public static IEnumerable<WebPageWithDocument> GetAllPagesUnderWithDocument(Uri urlRoot, int delayBetweenPagesInSeconds, Regex[] excludedPaths)
{
// Get the root page ...
HttpWebResponse webResponse = FetchWebPageWithRetries(urlRoot);
if (webResponse.ResponseUri.AbsoluteUri != urlRoot.AbsoluteUri)
{
Console.WriteLine("*** ROOT REQUEST WAS REDIRECTED USING: " + webResponse.ResponseUri + "***");
urlRoot = webResponse.ResponseUri;
}
var queue = new QueueWithDeduping<PendingCrawlItem>();
var start = PendingCrawlItem.Factory(urlRoot:urlRoot, href:urlRoot, referrer:urlRoot);
queue.Enqueue(start);
while (queue.Count > 0)
{
// pull an item off the queue, inspect it and deal with it
var nextItem = queue.Dequeue();
if (excludedPaths.Any(p => p.IsMatch(nextItem.Uri.AbsoluteUri)))
{
Console.WriteLine("Skipping " + nextItem.Uri + " because path is excluded");
continue;
}
var result = ProcessNextItem(nextItem, queue);
yield return result;
// And delay but only on internal pages - external pages don't count
if (!(result.WebPage is WebPage.External))
Thread.Sleep(delayBetweenPagesInSeconds);
}
}