Cake\Localized\Validation\JpValidation::hiragana PHP Метод

hiragana() публичный статический Метод

Checks hiragana ぁ-ゖー
public static hiragana ( string $check, boolean $allowSpace = true ) : boolean
$check string The value to check.
$allowSpace boolean Allow double-byte space.
Результат boolean Success.
    public static function hiragana($check, $allowSpace = true)
    {
        if ($allowSpace) {
            $pattern = '/^(\\xe3(\\x80\\x80|\\x81[\\x81-\\xbf]|\\x82[\\x80-\\x96]|\\x83\\xbc))*$/';
        } else {
            $pattern = '/^(\\xe3(\\x81[\\x81-\\xbf]|\\x82[\\x80-\\x96]|\\x83\\xbc))*$/';
        }
        return (bool) preg_match($pattern, $check);
    }

Usage Example

Пример #1
0
 /**
  * test the hiragana method of JpValidation
  *
  * @return void
  */
 public function testHiragana()
 {
     $this->assertTrue(JpValidation::hiragana('ぁい ゔえおー'));
     $this->assertFalse(JpValidation::hiragana('-'));
     $this->assertFalse(JpValidation::hiragana('0'));
     $this->assertFalse(JpValidation::hiragana('ア'));
     $this->assertFalse(JpValidation::hiragana('亜'));
     $this->assertFalse(JpValidation::hiragana('ぁい ゔえおー', false));
 }