I currently have 2 regular expressions to match. I need to match either of them
I am currently using this code:
$string = '000.400.101';
$regex1 = "^(000\.000\.|000\.100\.1|000\.[36])";
$regex2 = "^(000\.400\.0|000\.400\.100)";
$result = (preg_match('/'.$regex1.'/', $string) ||
preg_match('/'.$regex2.'/', $string)) ? 1 : 0 ;
I would like to shorten this and clean it up a little. Would the below be equivalent:
$result = (preg_match('/'.$regex1.'|'.$regex2.'/', $string)) ? 1 : 0 ;