Optimize assertLocale regexp

This commit is contained in:
Jérémy Derussé 2014-07-22 23:54:07 +02:00
parent 9572918064
commit 537c39b11e
1 changed files with 1 additions and 1 deletions

View File

@ -308,7 +308,7 @@ class Translator implements TranslatorInterface
*/
private function assertValidLocale($locale)
{
if (0 !== preg_match('/[^a-z0-9@_\\.\\-]+/i', $locale, $match)) {
if (1 !== preg_match('/^[a-z0-9@_\\.\\-]*$/i', $locale)) {
throw new \InvalidArgumentException(sprintf('Invalid locale: %s.', $locale));
}
}