这些值将采用这种格式 123-123-123-12345,我希望 preg_match 可以使用它。你能看出这个正则表达式有什么问题吗?
foreach($elem as $key=>$value) {
// Have tried this With and without the + before the $ as well
if(preg_match("/^[0-9]{3}\-[0-9]{3}\-[0-9]{3}\-[0-9]{5}+$/", $value)) {
echo "Yeah match Elm: ".$value."<br />";
} else {
echo "Boo Hoo Elm: '".$value."'<br />";
}
}
也试过
/^\d{3}\-\d{3}\-\d{3}\-\d{5}+$/
//With and without the + before the $
他们都失败了 Boo Hoo ;(
编辑:
var_dump($elem)
array(3) { [0]=> string(1) "c" [1]=> string(0) "" [2]=> string(36) "123-123-123-12345" }