3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\I18n\Filter
;
14 class Alpha
extends Alnum
17 * Defined by Zend\Filter\FilterInterface
19 * Returns the string $value, removing all but alphabetic characters
21 * @param string $value
24 public function filter($value)
26 $whiteSpace = $this->options
['allow_white_space'] ?
'\s' : '';
27 $language = Locale
::getPrimaryLanguage($this->getLocale());
29 if (!static::hasPcreUnicodeSupport()) {
30 // POSIX named classes are not supported, use alternative [a-zA-Z] match
31 $pattern = '/[^a-zA-Z' . $whiteSpace . ']/';
32 } elseif ($language == 'ja' ||
$language == 'ko' ||
$language == 'zh') {
33 // Use english alphabet
34 $pattern = '/[^a-zA-Z' . $whiteSpace . ']/u';
36 // Use native language alphabet
37 $pattern = '/[^\p{L}' . $whiteSpace . ']/u';
40 return preg_replace($pattern, '', (string) $value);