public bool IsPhone(string input) { string pattern = "^\\(0\\d{2}\\)[- ]?\\d{8}$|^0\\d{2}[- ]?\\d{8}$|^\\(0\\d{3}\\)[- ]?\\d{7}$|^0\\d{3}[- ]?\\d{7}$"; Regex regex = new Regex(pattern); return regex.IsMatch(input); }
时间: 2024-10-02 09:43:58
public bool IsPhone(string input) { string pattern = "^\\(0\\d{2}\\)[- ]?\\d{8}$|^0\\d{2}[- ]?\\d{8}$|^\\(0\\d{3}\\)[- ]?\\d{7}$|^0\\d{3}[- ]?\\d{7}$"; Regex regex = new Regex(pattern); return regex.IsMatch(input); }