📌  相关文章
📜  正则表达式仅接受 10 位数的手机号码 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:41.379000             🧑  作者: Mango

代码示例1
Copy CodeRegex reg = new Regex(@"^[0-9]{10}$");
string inputOK = "9876543214";
string inputBad1 = "876543214";
string inputBad2 = "09876543214";
if (reg.IsMatch(inputOK)) Console.WriteLine("OK");
if (!reg.IsMatch(inputBad1)) Console.WriteLine("OK");
if (!reg.IsMatch(inputBad2)) Console.WriteLine("OK");