Código
$sExpReg = ''; if( $sType == "CHAR" ){ $sExpReg = "/^[a-z]+$/i"; } # CHAR = String elseif( $sType == "NUM" ){ $sExpReg = "/^[[:digit:]]+$/"; } # NUM = Numbers elseif( $sType == "ALL" ){ $sExpReg = "/^[[:alnum:]]+$/"; } # ALL = String and Numbers else{ return 0; } }