任何人都可以帮助将这个php正则表达式转换为js兼容的吗?
$delimiter = "-";
$phone = "some number from the client";
var_dump(
preg_match($phone,"|^([0-9]{1,3}".$delimiter."[0-9]{1,4}".$delimiter."[0-9]{4,12}(#[0-9]{1,4})?)$|")
);
由于
答案 0 :(得分:1)
var delimiter = "-",
phone = "8-989-895",
re = new RegExp("^[0-9]{1,3}"+delimiter+"[0-9]{1,4}"+delimiter+"[0-9]{4,12}(?:[0-9]{1,4})?$");
console.log(re.test(phone));