private static bool IsBot(string userAgent)
{
if (userAgent != null)
{
foreach (string bot in BotUserAgents)
{
if (new Regex(@"\A" + new Regex(@"\.|\$|\^|\{|\[|\(|\||\)|\*|\+|\?|\\").Replace(bot, ch => @"\" + ch).Replace('_', '.').Replace("%", ".*") + @"\z", RegexOptions.Singleline).IsMatch(userAgent))
{
return true;
}
}
}
return false;
}