Good to know about @ as a delimeter. The problem for me seems to be that a string of "_" passes the regex (and the tep_not_null). I changed
if( preg_match( '@[0-9_]@', $detail['path'] ) ) {
to:
if( preg_match( '@[0-9_](?=.*\d)@', $detail['path'] ) ) {
and it seems to work since it forces the regex to match at least one digit so a category separator alone doesn't break it.