Created
October 2, 2017 07:56
-
-
Save vitqst/fc7adaaa36c5d7b8659e848e2fae5922 to your computer and use it in GitHub Desktop.
This is regex for who looking for regex japan text -->
This file contains 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 | |
#### DEFINE #### | |
const REGEX_JAPAN_TEXT = | |
'/[^\x{3041}-\x{3096}' . // Hiragana | |
'\x{3400}-\x{4DB5}\x{4E00}-\x{9FCB}\x{F900}-\x{FA6A}\x{2E80}-\x{2FD5}' . // Kanji | |
'\x{FF5F}-\x{FF9F}' . // Katakana (Half Width) | |
'\x{30A0}-\x{30FF}]/u'; // Katakana (Full Width) | |
const REGEX_HIRAGANA = '/[^\x{3041}-\x{3096}]/u'; | |
const REGEX_KANJI = '/[^\x{3400}-\x{4DB5}\x{4E00}-\x{9FCB}\x{F900}-\x{FA6A}\x{2E80}-\x{2FD5}]/u'; | |
const REGEX_KATAKANA_HALF = '/[^\x{FF5F}-\x{FF9F}]/u'; | |
const REGEX_KATAKANA_FULL = '/[^\x{30A0}-\x{30FF}]/u'; | |
#### Using ##### | |
$inputValue = 'ァ ア ィ イ ゥ ウ ェ エ ォ オ カ ガ 0 1 a b c' | |
$strJapan = preg_replace(REGEX_JAPAN_TEXT, "", $inputValue); // it will be get ァアィイゥウェエォオカガ only |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment