JpnForPhp\Analyzer\Analyzer::countKatakana PHP Method

countKatakana() public static method

Count number of katakana within the specified string. Chōonpu (http://en.wikipedia.org/wiki/Chōonpu) is considered as Katakana here.
public static countKatakana ( string $str ) : integer
$str string The input string.
return integer Returns the number of katakana
    public static function countKatakana($str)
    {
        $matches = array();
        return preg_match_all(Helper::PREG_PATTERN_KATAKANA, $str, $matches);
    }

Usage Example

Beispiel #1
0
 public function testCountKatakanaWhenSpecialKatakana()
 {
     $result = Analyzer::countKatakana('㋐㌒㌕');
     $this->assertEquals(3, $result);
 }