29 lines
825 B
C#
29 lines
825 B
C#
using System;
|
|
using System.Text.RegularExpressions;
|
|
namespace SPSolutions
|
|
{
|
|
public class ValidationUtil
|
|
{
|
|
public static string EmailExpression = "^([a-zA-Z0-9_\\-\\.\\+\\']+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
|
|
public static string ImageFilenameExpression = "(.*?)\\.(jpg|jpeg|png|gif)$";
|
|
public static bool IsEmail(string input)
|
|
{
|
|
if (string.IsNullOrEmpty(input))
|
|
{
|
|
return false;
|
|
}
|
|
Regex regex = new Regex(ValidationUtil.EmailExpression);
|
|
return regex.IsMatch(input);
|
|
}
|
|
public static bool IsImageFilename(string input)
|
|
{
|
|
if (string.IsNullOrEmpty(input))
|
|
{
|
|
return false;
|
|
}
|
|
Regex regex = new Regex(ValidationUtil.ImageFilenameExpression, RegexOptions.IgnoreCase);
|
|
return regex.IsMatch(input);
|
|
}
|
|
}
|
|
}
|