This is what I came up with (not beautifully concise, but it works):
$data = array('ABC123', 'ABC-123', 'ABC', '123', 'xyz');
foreach($data as $test)
{
echo "<p>'$test' is ";
if(preg_match('/[^A-Z0-9-]/', $test) or
!preg_match('/([A-Z][A-Z-]*[0-9])|([0-9][0-9-]*[A-Z])/', $test))
{
echo "NOT ";
}
echo "valid.</p>\n";
}
(Add an i after the last "/" of each regex if you want to allow lower case letters, too.)