php正则电话号

400电话的正则/^400[0-9]{7}/

800电话正则/^800[0-9]{7}/

手机号码正则/^1(3|4|7|5|8)([0-9]{9})/

座机号码正则^0[0-9]{2,3}-[0-9]{8}

要匹配其中之一就在中间以|隔开

(400正则)|(800正则)|(手机号)|(座机号)|

    $phone = preg_replace("/\s| /","",$phone);

	单独验证400正则
   if (preg_match("/^(400[0-9]{7}/",$phone)) {
        return true;
    }
		
	合在一起 正则	
    // 400/800 正则校验 
    if (preg_match("/^(400[0-9]{7})|(800[0-9]{7})/",$phone)) {
        return true;
    }

你可能感兴趣的:(php,java,开发语言)