The correct check is preg_match( '/[a-z]{2}(_[A-Z]{2})?/', $_REQUEST['locale'] )