function telephoneCheck(str) {
let hand = /^1{0,1} {0,1}(\(\d{3}\)|\d{3})-{0,1} {0,1}\d{3}-{0,1} {0,1}\d{4}$/;
return hand.test(str);
}
telephoneCheck("555-555-5555");
提供的测试用例都过了,有其他问题请回复
-
telephoneCheck("555-555-5555")
应返回一个布尔值。 -
telephoneCheck("1 555-555-5555")
应返回true
。 -
telephoneCheck("1 (555) 555-5555")
应返回true
。 -
telephoneCheck("5555555555")
应返回true
。 -
telephoneCheck("555-555-5555")
应返回true
。 -
telephoneCheck("(555)555-5555")
应返回true
。 -
telephoneCheck("1(555)555-5555")
应返回true
。 -
等待中:
telephoneCheck("555-5555")
应返回false
。