Created
June 6, 2012 11:49
-
-
Save sasezaki/2881443 to your computer and use it in GitHub Desktop.
ZF2-170
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once __DIR__.'/library/Zend/Loader/StandardAutoloader.php'; | |
| use Zend\Loader\StandardAutoloader; | |
| use Zend\Filter\StringTrim; | |
| $autoloader = new StandardAutoloader; | |
| $autoloader->register(); | |
| class Before extends StringTrim | |
| { | |
| protected function _unicodeTrim($value, $charlist = '\\\\s') | |
| { | |
| $chars = preg_replace( | |
| array( '/[\^\-\]\\\]/S', '/\\\{4}/S', '/\//'), | |
| array( '\\\\\\0', '\\', '\/' ), | |
| $charlist | |
| ); | |
| $pattern = '^[' . $chars . ']*|[' . $chars . ']*$'; | |
| return preg_replace("/$pattern/usSD", '', $value); | |
| } | |
| } | |
| class After extends StringTrim | |
| { | |
| protected function _unicodeTrim($value, $charlist = '\\\\s') | |
| { | |
| $chars = preg_replace( | |
| array( '/[\^\-\]\\\]/S', '/\\\{4}/S', '/\//'), | |
| array( '\\\\\\0', '\\', '\/' ), | |
| $charlist | |
| ); | |
| $pattern = '^[' . $chars . ']*|[' . $chars . ']*$'; | |
| return preg_replace("/$pattern/sSD", '', $value); | |
| } | |
| } | |
| $filter = new Before(); | |
| $value = $filter->filter('あいうえお '); | |
| var_dump($value); // string(15) "あいうえお" | |
| $filter = new After(); | |
| $value = $filter->filter('あいうえお '); | |
| var_dump($value); // string(18) "あいうえお " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment