ChouBox/Utile/HuanMeng.DotNetCore/Utility/PhoneNumberValidator.cs
2025-04-23 19:20:23 +08:00

26 lines
633 B
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace HuanMeng.DotNetCore.Utility;
/// <summary>
/// 手机号
/// </summary>
public class PhoneNumberValidator
{
// 正则表达式用于匹配手机号码。可以根据需要调整以适应不同的国家或地区。
private static readonly Regex phoneNumberRegex = new Regex(@"^(1[3-9]\d{9})$");
public static bool IsPhoneNumber(string input)
{
if (string.IsNullOrWhiteSpace(input))
{
return false;
}
return phoneNumberRegex.IsMatch(input);
}
}