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\Filter\Word
;
12 use Zend\Stdlib\StringUtils
;
14 class CamelCaseToSeparator
extends AbstractSeparator
17 * Defined by Zend\Filter\Filter
19 * @param string $value
22 public function filter($value)
24 if (StringUtils
::hasPcreUnicodeSupport()) {
25 $pattern = array('#(?<=(?:\p{Lu}))(\p{Lu}\p{Ll})#', '#(?<=(?:\p{Ll}|\p{Nd}))(\p{Lu})#');
26 $replacement = array($this->separator
. '\1', $this->separator
. '\1');
28 $pattern = array('#(?<=(?:[A-Z]))([A-Z]+)([A-Z][a-z])#', '#(?<=(?:[a-z0-9]))([A-Z])#');
29 $replacement = array('\1' . $this->separator
. '\2', $this->separator
. '\1');
32 return preg_replace($pattern, $replacement, $value);