新增方法

This commit is contained in:
不做码农
2021-12-21 17:56:54 +08:00
parent 4903bc130d
commit f2c83958b4
3 changed files with 63 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace ZR.Common
{
@@ -60,5 +61,23 @@ namespace ZR.Common
: (diffday / 7)) + 1 + (dayInMonth > firstWeekEndDay ? 1 : 0);
return weekNumInMonth;
}
/// <summary>
/// 判断一个字符串是否为url
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static bool IsUrl(string str)
{
try
{
string Url = @"^http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?$";
return Regex.IsMatch(str, Url);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
}
}
}