111,092
社区成员




/// <summary>
/// 是否为Uri
/// </summary>
/// <param name="s">判断字符串</param>
/// <returns></returns>
public static bool IsUri(string s)
{
Uri u;
return Uri.TryCreate(s, UriKind.RelativeOrAbsolute,out u);
}
/// <summary>
/// 检测串值是否为合法的网址格式
/// </summary>
/// <param name="strValue">要检测的String值</param>
/// <returns>成功返回true 失败返回false</returns>
public static bool CheckIsUrlFormat(string strValue)
{
return Utility.CheckIsFormat(@"(http://)?([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?", strValue);
}
/// <summary>
/// 检测串值是否为合法的格式
/// </summary>
/// <param name="strRegex">正则表达式</param>
/// <param name="strValue">要检测的String值</param>
/// <returns>成功返回true 失败返回false</returns>
public static bool CheckIsFormat(string strRegex,string strValue)
{
if(strValue != null && strValue.Trim() != "")
{
Regex re = new Regex(strRegex);
if (re.IsMatch(strValue))
{
return true;
}
else
{
return false;
}
}
return false;
}